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
npm install google-map-bounds-limit
UMD
We also have a standalone build, which you simply can drop in via a <script/>
tag:
The limitMap()
function is set on the window
object. The dist/
directory contains the umd-build.
How to use
; const map = ...;const maxBounds = -40 -90 38 70; ;
Notes
- To prevent zooming we currently use
google.maps.Map.setOptions({minZoom: <value>})
. If you instantiate your map with aminZoom
option, it might be overwritten. - For a "global" limit use these bounds:
const maxBounds = -85 -175 85 175;
The actual lat/lng limits (+/-90 and +/-180) won't be reached.