【问题标题】:Dragging marker in google maps and changing the coordinates corresponding to it在谷歌地图中拖动标记并更改与之对应的坐标
【发布时间】:2015-05-02 12:49:46
【问题描述】:

如果我在谷歌地图上有两个标记,并且我在变量(fromLan,fromLat)中保留第一个标记的经度和纬度,在变量(toLan,toLat)中保留第二个标记的经度和纬度。 我想在拖动其中一个时更改此标记的经度和纬度,以便知道是更改 (fromLan, fromLat) 变量还是 (toLan, toLat) 变量。

【问题讨论】:

    标签: javascript google-maps markers


    【解决方案1】:

    为每个标记添加一个拖动监听器:

    google.maps.event.addListener(fromMarker, 'dragend', function(){
     fromLat = this.getPosition().lat();
     fromLng = this.getPosition().lng();
    });
    
    google.maps.event.addListener(toMarker, 'dragend', function(){
     toLat = this.getPosition().lat();
     toLng = this.getPosition().lng();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 2016-04-10
      • 2012-05-08
      • 2014-08-28
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多