I'm trying to figure out how to make my map unable to pan beyond the north
or south poles. I don't know if there is an existing script, but I couldn't
find anything and tried my hand at something. Unfortunately its flawed
because it doesn't seem like there is a 90 or -90 latitude in the maps API
(it just seems the values reported back get excedingly close to 90 but never
reach it or pass beyond it) and that it causes stack size errors.
Anyone know of a simpler method that actually works?
google.maps.event.addListener(map, "center_changed", mapDragged);
function mapDragged(){
var bounds = map.getBounds();
if(bounds.getSouthWest().lat() < -90){
map.fitBounds(new google.maps.LatLngBounds(new
google.maps.LatLng(bounds.getSouthWest().lat(),
bounds.getSouthWest().lng()), new google.maps.LatLng(-90,
bounds.getNorthEast().lng())));
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/9v7aVnhbp2YJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.