Unfortunately being able to upload it is tricky - I'm forbidden to go live with 
it until it works! They have a staging server but I'm not allowed to give THAT 
URL out either. It would take me all day to deconstruct what I have for demo 
purposes :(

Essentially what our client wants is an infowindow which appears without having 
to pan the map. I've written a custom overlay to display the window (he didn't 
want the bubble either), and the rule is essentially that the window will 
appear in different positions depending on the marker position relative to the 
map.

If the marker is too close to the left edge (and therefore some of the window 
would be off the left edge), display the window to the RIGHT of the marker.

If the marker is too close to the bottom edge, display the window ABOVE the 
marker.

If the marker is too close to the right edge, display the window to the LEFT of 
the marker.

These rules can also be combined so a marker in the bottom left corner, for 
example, the window would open above and to the right.

I have all of the logic for this but I just can't make it work - even if I 
offset the markers and alert the new left and top positions the window winds up 
BELOW the marker regardless. If I use fromLatLngToDivPixel then the result of 
that function doesn't change on a map move, and if I use 
fromLatLngToContainerPixel the window end up MILES away for some reason.

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Mathieu Alengrin
Sent: 16 June 2009 10:29
To: Google Maps API
Subject: Re: Update result of fromLatLngToDivPixel if map is moved?


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

Reply via email to