Created
January 17, 2013 20:19
-
-
Save mturnwall/4559361 to your computer and use it in GitHub Desktop.
Make sure google maps isn't zoomed too far in when updating locations. You might want this because when one location is returned the map will be zoomed in as far as it can go. So you might want to make sure the zoom level never goes past a certain point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
call this snippet after you call map.fitBounds(); | |
replace "map" with the instance to your map | |
change the zoomThreshold to the zoom level you want the map never to zoom | |
past when loading locations | |
*/ | |
google.maps.event.addListenerOnce(map, 'zoom_changed', function() { | |
var oldZoom = map.getZoom(), | |
zoomThreshold = 16; | |
if (oldZoom > zoomThreshold) { | |
map.setZoom(zoomThreshold); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment