# google-map-bounds-limit

> This module limits the map movement and zooming functionality of a provided google maps instance to a given bounds value.

Latest version **0.1.0** (published 2016-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install google-map-bounds-limit
pnpm add google-map-bounds-limit
yarn add google-map-bounds-limit
bun add google-map-bounds-limit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-07-05 |
| First published | 2016-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rich_pb, scarysize |

## Links

- npm: https://www.npmjs.com/package/google-map-bounds-limit
- Repository: https://github.com/ubilabs/google-map-bounds-limit
- Homepage: https://github.com/ubilabs/google-map-bounds-limit#readme
- Issues: https://github.com/ubilabs/google-map-bounds-limit/issues
- npm.io page: https://npm.io/package/google-map-bounds-limit

## Recent versions

- 0.1.0 (latest) — 2016-07-05
- 0.0.3 — 2016-07-01
- 0.0.3-0 — 2016-07-01
- 0.0.2-0 — 2016-07-01
- 0.0.1 — 2016-07-01

## README

# google maps bounds limit

This module limits the map movement and zooming functionality of a provided google maps instance to a given bounds value.

## Installation

### npm

```sh
npm install google-map-bounds-limit
```

### UMD

We also have a standalone build, which you simply can drop in via a `<script/>` tag:

```html
  <script src="google-map-bounds-limit.js"></script>
```

The `limitMap()` function is set on the `window` object. The `dist/` directory contains the umd-build.

## How to use

```js
import limitMap from 'google-map-bounds-limit';

const map = new google.maps.Map(...);
const maxBounds = new google.maps.LatLngBounds(
  new google.maps.LatLng(-40, -90),
  new google.maps.LatLng(38, 70)
);

limitMap(map, maxBounds);
```

## Notes
- To prevent zooming we currently use `google.maps.Map.setOptions({minZoom: <value>})`. If you instantiate your map with a `minZoom` option, it might be overwritten.
- For a "global" limit use these bounds:
```js
const maxBounds = new google.maps.LatLngBounds(
  new google.maps.LatLng(-85, -175),
  new google.maps.LatLng(85, 175)
);
```
The actual lat/lng limits (+/-90 and +/-180) won't be reached.

## Resources
- [**LatLngBounds Class** (Google Maps JS API Reference)](https://developers.google.com/maps/documentation/javascript/reference#LatLngBounds)
- [**LatLng Class** (Google Maps JS API Reference)](https://developers.google.com/maps/documentation/javascript/reference#LatLng)

---
_Source: https://npm.io/package/google-map-bounds-limit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
