Google Maps Polyline点击不会触发PolyMouseEvent

art*_*nce 4 javascript google-maps-api-3

我试图在折线的路径中获取边缘的索引,因为它在文档中写入.但是,每当我在折线上触发click事件时,我都会得到未定义的值.

这是我的代码:edge,path和vertex都是未定义的

route = new google.maps.Polyline({
path: polyLineArray,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 5,
clickable: true,
editable: false
});

google.maps.event.addListener(route, 'click', function(evt) {           
  console.log("route click1: " + evt.edge);
  console.log("route click2: " + evt.path);
  console.log("route click2: " + evt.vertex);
  console.log("route click3: " + evt);
  for(var property in evt) {
   console.log("route click4: " + property + " - " + evt[property]);
  }
Run Code Online (Sandbox Code Playgroud)

}};

我在这里错过了什么吗?非常感谢

geo*_*zip 9

我在测试用例中看到了相同的结果

进一步的测试,看起来他们都可以在"editiable"折线,如果你点击的白色正方形的顶点是真实的,路径如果编辑折线,并单击"新建"顶点之一是真实的". 测试可编辑折线的情况

仔细观察文档,很明显它只适用于可编辑折线/多边形:

google.maps.PolyMouseEvent object
This object is returned from mouse events on polylines and polygons.

This object extends MouseEvent.
Properties
Properties | Type   | Description
edge       | number | The index of the edge within the path beneath the cursor when 
                    | the event occurred, if the event occurred on a mid-point on an 
                    | editable polygon.
path       | number | The index of the path beneath the cursor when the event 
                    | occurred, if the event occurred on a vertex and the polygon
                    | is editable. Otherwise undefined.
vertex     | number | The index of the vertex beneath the cursor when the event 
                    | occurred, if the event occurred on a vertex and the polyline or 
                    | polygon is editable. If the event does not occur on a vertex, 
                    | the value is undefined.
Run Code Online (Sandbox Code Playgroud)

更多信息.点击小白色方块("编辑手柄")给出一个顶点#或一个边数,还没有找到一种方法使路径任何东西,但未定义,但这可能是因为到目前为止我只使用折线.