Re: API Bug: map.center equal open infoWindow anchor?
Workaround found.
I would rather hear from Google folks that this will be fixed in the
API. In short, map.getCenterLatLng() should return the coordinates of
the map center while a marker's infoWindow is open, but currently it
does not, and returns the marker location point instead. I wrote a
short workaround function but it is silly to use it, the API should be
fixed. Here is my prototype workaround, which utilizes
map.getBoundsLatLng() instead of getCenterLatLng().
function getMapCenter() {
var bounds = map.getBoundsLatLng();
cenlat = (bounds.maxY - bounds.minY)/2.0 + bounds.minY;
cenlng = (bounds.maxX - bounds.minX)/2.0 + bounds.minX;
var cpoint = new GPoint(cenlng,cenlat);
return cpoint;
}
This is VERY minimally tested, and I don't think it is robust... it
probably fails when wrapping around the Prime Meridian or the poles or
some such, but for now it works fine when just working in a local area
like the U.S. I would appreciate a better approach, if someone else
has addressed this issue.
+lupa+
0 Comments:
Yorum Gönder
<< Home