How to track event changes to a polygon with Google Maps API

纵然是瞬间 提交于 2019-12-04 03:53:39
Dr.Molle

these events are defined for MVCArray, a polyline is not a MVCArray. You must observe the events for the path of the polyline(which is a MVCArray) instead. Furthermore you can't add a listener to an object that isn't created yet. The polygon is not available before polygoncomplete, so you must add the listeners inside the polygoncomplete-callback:

google.maps.event.addListener(drawingManager,'polygoncomplete',function(polygon) {

  // complete functions

  google.maps.event.addListener(thePath, 'set_at', function() {
    // complete functions
  });

  google.maps.event.addListener(thePath, 'insert_at', function() {
    // complete functions
  });

});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!