Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 google maps api v3中多段线顶点的鼠标移动事件_Google Maps Api 3_Polyline_Google Polyline - Fatal编程技术网

Google maps api 3 google maps api v3中多段线顶点的鼠标移动事件

Google maps api 3 google maps api v3中多段线顶点的鼠标移动事件,google-maps-api-3,polyline,google-polyline,Google Maps Api 3,Polyline,Google Polyline,在可编辑多段线上移动顶点时,我希望显示一个信息窗口。 此信息将显示到多段线上上一个顶点的距离和方向。当我放下顶点时,信息窗口必须关闭。 问题是多段线在顶点上没有拖动事件。我将尝试使用polyline的mousemove,但它会在移动完成后触发。 在下一段代码中,我将展示一个我所说的示例。我有一条多段线飞行路线。如果单击最后一个顶点,我希望同时移动一个标记。但它不起作用。移动完成后,将移动标记 google.maps.event.addListener(flightPath, 'mousemove

在可编辑多段线上移动顶点时,我希望显示一个信息窗口。 此信息将显示到多段线上上一个顶点的距离和方向。当我放下顶点时,信息窗口必须关闭。 问题是多段线在顶点上没有拖动事件。我将尝试使用polyline的mousemove,但它会在移动完成后触发。 在下一段代码中,我将展示一个我所说的示例。我有一条多段线飞行路线。如果单击最后一个顶点,我希望同时移动一个标记。但它不起作用。移动完成后,将移动标记

google.maps.event.addListener(flightPath, 'mousemove', function (event) {
   if (typeof event.vertex === "undefined") {
        moveline = 0
   }
   else {
       if (event.vertex == (flightPath.getPath().getLength()-1)) {
            var path = flightPath.getPath();
            marker.setPosition(path.getAt(event.vertex));
       }
   }
});
有什么建议吗

注意:我的多段线是可编辑的


感谢您可以管理标记上的拖动结束事件并更改顶点的取消锁定:

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

var vertex = marker.get('vertex');

var path = flightPath.getPath();

var newPath = Array.prototype.slice.call(path).filter(
function(element, index){
    return index < vertex;
}).concat([evt.latLng],
Array.prototype.slice.call(path).filter(
function(element, index){
    return index > vertex;
}));
flightPath.setPath(newPath);


});

很抱歉我的英语不好,但我希望能有所帮助。

谢谢你的回答,但它没有达到我想要的效果。在发布此问题之前,我尝试使用google地图示例将标记绑定到顶点,但我的多段线是editable=true。然后我可以移动顶点而不移动标记,尽管它们已绑定。