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

前端 未结 1 2203
谎友^
谎友^ 2021-02-20 12:39

I\'m currently building a \'search an area\' feature for a site we\'re working on. A bit like the one on Rightmove.

I\'ve got everything up and running except the abilit

相关标签:
1条回答
  • 2021-02-20 13:21

    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
      });
    
    });
    
    0 讨论(0)
提交回复
热议问题