简体   繁体   中英

Getting New location from a Moveable marker

I've created a page that has a static map on, complete with marker.

I have put a link underneath that then does a POPUP page with a larger map - same marker, but draggable.

What I am struggling with is;

a) Getting the new coordinates after a drag of the moveable marker. I have the following Eventlistener code:

google.maps.event.addListener(marker, 'dragend', function() {

   updateMarkerStatus('Drag ended'); 

   geocodePosition(marker.getPosition());   
document.write("I'm HERE");
}); 

..and am getting the 'I'm HERE' - but how do I get the new coordinates?

and

b) Once I have these values - how do I pass them back to the page that called the POPUP.

(My JS skills are limited, most of the site is in php and HTML.

Any help greatly appreciated.

Phil

var newPosition = marker.getPosition();
marker.getPosition() 

should return the current coordinates of the marker. So...

marker.getPosition().lat() 

should give you the current latitude and

marker.getPosition().lng() 

should give you the current longitude. What does geocodePosition() do? Need more context to answer your second question.

Sorry about the confused comments - was trying to paste code and was running out of characters.

Basically was saying thank you for the help so far and I have managed to get the new marker locations.

The 2nd part of the question is a JS query really.

I have a link on the main page, under a static map, as below;

<a href='adjustmap.php?lat=$retLat&long=$retLong' onClick='return popup(this, \"adjustmap\")'>Click Here to Fine Tune Location</a> 

The onclick creates the popup window with a bigger map in it with the draggable marker in. I now have the new coordinates in that popup - how do I get them back to the main form?

Phil

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM