【问题标题】:Google Map API v.3 Drawing library: fireing events during editing polylinesGoogle Map API v3 绘图库:在编辑折线期间触发事件
【发布时间】:2013-02-10 16:57:26
【问题描述】:

我正在将应用程序从 API v.2 移植到 API v.3

应用程序具有允许用户绘制折线的功能。每次插入新顶点时,路径长度都会更新。如何在 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);
        }
    });

【问题讨论】:

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


    【解决方案1】:

    我知道这个问题已经很老了。以防万一有人遇到同样的问题: The editing event api 很有用:

    google.maps.event.addListener(your_polyline.getPath(), 'insert_at', function(index) {
    // 当你在你的折线上插入一个新点时,做你喜欢的事。
    });
    
    google.maps.event.addListener(your_polyline.getPath(), 'set_at', function(index) {
    // 当您在此处移动多段线上的现有点时,做您喜欢的事情。
    });

    【讨论】:

      猜你喜欢
      • 2013-03-15
      • 1970-01-01
      • 2014-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-19
      • 2015-09-21
      • 2012-04-18
      相关资源
      最近更新 更多