Hi
I noticed some strange behavior of GLatLngBound
Initially, GLatLngBound returns the sw, ne bound. However if you keep
dragging the map till it wraps around, you will notice that the bound
seems like se, nw. And the containsLatLng() function stops working
properly.
I pasted a sample code below that may reproduce this issue. I get the
initial center point on map loading, and at each drag event, I will
check if the current bound contains the original map center. You
will see it malfunctions after the map wraps around.
######################################################
var bounds
var pt;
var lat, lng;
var map;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 4);
pt = map.getCenter();
lat = pt.lat();
lng = pt.lng();
GEvent.addListener(map, "dragend", onDragEnd);
}
}
function onDragEnd() {
map.setZoom(4);
bounds = map.getBounds();
console.log(bounds);
if(bounds.containsLatLng(new GLatLng(lat, lng))) {
console.log(lat+" "+lng+" "+" yes");
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
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-api?hl=en.