简体   繁体   English

拖动标记时获取起点和终点的纬度和经度

[英]get latitude and longitude of starting and ending point when a marker is dragged

I am working with google maps api.我正在使用谷歌地图 api。 I want to replace the latitude and longitude of previous position of a marker with the lat.我想用纬度替换标记先前位置的纬度和经度。 and lon.和隆。 of current position of the marker when it is dragged.拖动时标记的当前位置。 For this, I need the previous marker point.为此,我需要先前的标记点。 How to do this?这该怎么做?

PS I already know how to get coordinates of a marker, but I want to get the coordinates from which it was dragged. PS 我已经知道如何获取标记的坐标,但我想获取拖动它的坐标。

I have added a note which clearly specifies what I want to do.我添加了一个注释,清楚地说明了我想要做什么。 The quote was " I already know how to get coordinates of a marker, but I want to get the coordinates of position from which it was dragged."引用是“我已经知道如何获取标记的坐标,但我想获取拖动它的位置坐标。” In other words, I need to get the coordinates when dragging is started.换句话说,我需要在拖动开始时获取坐标。

After little extra efforts and search, I got the solution finally.经过一些额外的努力和搜索,我终于得到了解决方案。 I just need to call dragstart event.我只需要调用 dragstart 事件。

   google.maps.event.addListener(marker, 'dragstart', function(event) {
                 console.log(event.latLng);
              });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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