如果我在谷歌地图上有两个标记,并且我在变量(fromLan,fromLat)中保留第一个标记的经度和纬度,在变量(toLan,toLat)中保留第二个标记的经度和纬度。 我想在拖动其中之一时更改该标记的经度和纬度,以便知道是否更改 (fromLan, fromLat) 变量或 (toLan, toLat) 变量。
最佳答案
为每个标记添加一个拖尾监听器:
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();
});
关于javascript - 拖动谷歌地图中的标记并更改与其对应的坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30002497/