Hi, fromLatLngToContainerPixel() seems to work with scrolling, zooming and dragging. Do you have a link of what you're trying to do so we could see the context?
But if you position an overlay using the value returned by fromLatLngToContainerPixel() you might need to update it every times the map is zoomed or moved. Here is a code that works fine in the code playground (http://code.google.com/apis/ajax/playground/?exp=maps#map_simple) : ---------- function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); map.addControl(new GSmallMapControl()); var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); var latlng = new GLatLng(southWest.lat() + latSpan * Math.random (), southWest.lng() + lngSpan * Math.random ()); var marker = new GMarker(latlng, {draggable: true}) map.addOverlay(marker); GEvent.addListener(marker, "click", function() { alert(map.fromLatLngToContainerPixel(this.getLatLng())); }); } } ---------- Mathieu On Jun 16, 10:35 am, "Michael Price" <[email protected]> wrote: > Hi all, > > Yesterday I wrote to the list about getting the position of a marker > relative to the map edge. I got a couple of responses and was able to get > what I wanted using fromLatLngToDivPixel, allowing me to position a custom > overlay near a marker, offset from the result of that call. However, I need > the result to update if the map is scrolled or zoomed. I can do this using > fromLatLngToContainerPixel BUT for some reason this messes with the offset - > if I scroll a marker up, the offset of the overlay is FURTHER AWAY from the > marker. How can I update the result of fromLatLngToDivPixel when the map is > moved or zoomed? > > Regards, > > Michael Price --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
