It's certainly possible, Google manage to do the trickier case, where
they pan so that the whole infowindow becomes visible, but it's not
particularly simple.

I think you need to examine the cases - one where the left or right edge
is the critical factor, and the one where the top or bottom edge is.

Calculate the pixel offsets from the map centre to the marker location,
by converting the marker location with map.fromLatLngToContainerPixel()
and subtracting half the width and height of the container.

Lets call the offsets dX and dY, and the half width and height of the
container hW and hH. Then you need to determine whether abs(dX-hW) is
larger than abs(dY/hH). Use whichever of those is larger as your scale
factor, sF. Multiply it by something like 1.05, Then calculate
  var p = new GPoint(hW + dX/sF, hH + dY/sF);
convert that back from pixels to lat/lng and pan there.

The 1.05 is a fudge factor. Without it your marker would be placed
*exactly* on the edge of the viewport, which isn't very useful,
particularly for the top edge of the map. You could fudge by a specific
number of pixels by tweaking hW and hH at relevant points in the
calculation, but getting the sign right isn't trivial.

-- 
Mike Williams
http://econym.org.uk/gmap



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to