2013-02-25 60 views
1

我移植的应用程序从API第2版到3.0版API谷歌地图API 3.0版绘图库:在编辑折线

应用fireing事件有功能,允许用户绘制折线。每次插入新顶点时,路径长度都会更新。如何在v.3中执行此操作,因为绘图库仅在“polylinecomplete”上具有事件。 编辑事件描述here,只能用于现有折线。这并不使我感到开心,因为只有在完成绘图后才能收到我的多段线对象...

google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) { 
     if (event.type == google.maps.drawing.OverlayType.POLYLINE) { 
      my_polyline = event.overlay 
      drawingManager.setMap(null); 
     } 
    }); 

回答

0

我知道这个问题很老了。以防万一有人陷入同样的​​问题: The editing event api是非常有用的:

google.maps.event.addListener(your_polyline.getPath(), 'insert_at', function(index) { 
// Do what you like when you insert a new point on your polyline here. 
}); 

google.maps.event.addListener(your_polyline.getPath(), 'set_at', function(index) { 
// Do what you like when you move an existing point on your polyline here. 
});