When overlay
is a Google maps overlay and offsetx, offsety
is the pixel distance from the maps center that I want to pan latlong
to, the following works.
var projection = overlay.getProjection();
var pxlocation = projection.fromLatLngToContainerPixel(latlong);
map.panTo(projection.fromContainerPixelToLatLng(new google.maps.Point(pxlocation.x+offsetx,pxlocation.y+offsety)));
However, I don't always have an overlay on the map and map.getProjection()
returns a projection
, not a MapCanvasProjection
which does not have the methods I need.
Is there a way to do this without making an overlay specificaly for it?