On Mar 29, 9:01 pm, Zyada <[email protected]> wrote:
> My apologies for being a complete javascript noob.
>
> The page I am working on is supposed to allow the user to geolocate a
> place by right-clicking on the map, then dragging the marker or right-
> clicking in a different spot if they decide that the first marker
> isn't where they want it. This much I've got working.
>
> What I need to do next is to get the lat long from the marker, but the
> marker is being created in an event function; can I get the marker
> object from the map object?
>
> Or can I re-arrange my code so that the marker object isn't hidden
> inside a function?
>
> Or do I have to save the lat/long every time the marker is recreated
> or dropped?
>
> Here is my page:http://zyada-stuff.com/SpreadingRoots/temp.html
It seems to me that since it looks like you only ever have one marker
per map, and each marker could have a unique name, you could do:
var mapX = new GMap2(document.getElementById("map_canvas_X"));
mapX.setCenter(new GLatLng(31.25044240, -99.25060610), 6);
mapX.setUIToDefault();
GEvent.addListener(mapX,"singlerightclick", function(point, src,
overlay){
var cur_ll = mapX.fromContainerPixelToLatLng(point);
mapX.clearOverlays();
var map_markerX = new GMarker(cur_ll, {draggable: true})
map0.addOverlay(map_markerX);
} );
map_markerX is currently located at: map_markerX.getLatLng()
-- Larry
--
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.