Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
96
rated 0 times [  101] [ 5]  / answers: 1 / hits: 89390  / 12 Years ago, tue, august 7, 2012, 12:00:00

The Google Maps terrain view by default has unlimited panning of the map tile. You can use LatLngBounds() to limit this, but what are the maximum and minimum coordinates I should use to set the viewport as just the earth and not outside the map region?



Coordinates for North America:



var strictBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(28.70, -127.50),
new google.maps.LatLng(48.85, -55.90)
);


I've tried (+90, -180)(-90,180) to no luck.


More From » google-maps

 Answers
114

The links provided by @Marcelo & @Doc are good for understanding the derivation of the Lat Lng:





But if you just want an answer for the maximum bounds for Google Maps:



Latitude: -85 to +85 (actually -85.05115 for some reason)



Longitude: -180 to +180



Try it for yourself on the Google Maps:





(You may need to Zoom Out. See how the pin is at the edge of the world - these are the limits)



So in your code Try:



var strictBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(85, -180), // top left corner of map
new google.maps.LatLng(-85, 180) // bottom right corner
);


Please edit this wiki (or update your question) once you have the answer. Thanks


[#83787] Monday, August 6, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parisc

Total Points: 438
Total Questions: 119
Total Answers: 119

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;