Google Maps V3折线绘图/编辑/继续绘图

时间:2013-03-25 22:27:37

标签: google-maps google-maps-api-3 google-polyline

我正在寻找一种通过谷歌地图v3绘制折线的方法。完成后,可以编辑折线,然后继续绘制相同的折线。

我已经阅读了很多关于DrawingManager(在3.7中介绍)的内容,并阅读了大部分V3的API:

https://developers.google.com/maps/documentation/javascript/overlays#drawing_tools

其中显示了这样的例子:

https://google-developers.appspot.com/maps/documentation/javascript/examples/drawing-tools

developers.google示例非常棒,允许用户通过单击最后一个顶点来绘制和完成折线。但是一旦完成,我似乎无法找到如何继续绘制相同的折线。这可能吗?

我知道Google Maps API最高版本为10(冻结版)。我甚至看过他们的发布和实验版本,但那里没有谈论它。

我愿意接受任何建议。

2 个答案:

答案 0 :(得分:1)

DrawingManagerOptions中的PolylineOptions忽略路径属性。因此,您可以做的是在拉伸折线的末端和绘制新折线的开始时(在polylinecomplete事件上)绘制新的折线。

google.maps.event.addListener(drawingManager, 'polylinecomplete', function(event) {
      if (event.type == google.maps.drawing.OverlayType.POLYLINE) {
        //save last point
        //draw a new polyline to join last final point and this first point if this isn't the first polyline
      }
});

希望有所帮助

答案 1 :(得分:1)

使用Google创建的问题:http://code.google.com/p/gmaps-api-issues/issues/detail?id=5213 希望它变得更“喜欢”