Hi everyone,
I already asked this question on stackoverflow, but this is probably the better place to ask:
I am using Googles Map API v3. Can somebody explain the behavior of the map's bounding boxes to me?
Depending on the zoom level these bounds behave weird - when I zoom in it works as expected - the bounds stretch from the lower left corner of the pane to the upper right corner. As soon as I zoom out it get weirds - the bounding box splits up. You can reproduce this with the google examples and the attached code. Just zoom out until the maximum after running the code.
The wrong bounding boxes are really annoying - e.g. markers in between are not in the bounds of the map, although they are visible.
http://code.google.com/apis/maps/documentation/javascript/examples/map-simple.html
http://www.spotdiving.com/bug.png
var viewportBox;
google.maps.event.addListener(this.map, 'idle', function(event)
{
var bounds = map.getBounds();
var ne = bounds.getNorthEast();
var sw = bounds.getSouthWest();
var viewportPoints = [
ne, new google.maps.LatLng(ne.lat(), sw.lng()),
sw, new google.maps.LatLng(sw.lat(), ne.lng()), ne
];
if (viewportBox)
{
viewportBox.setPath(viewportPoints);
} else
{
viewportBox = new google.maps.Polyline({
path: viewportPoints,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 4
});
viewportBox.setMap(map);
}
});
I tried zooming out on the example you gave, but no box was drawn.
I'm guessing the question may be recast as "I'm having trouble drawing
rectangler bigger than a hemisphere"?
See
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/2b18cc2d32085ed8/cea7f4e3ccc0285a
for an example