I'm creating an array of polygons in Google Maps using the loadGeoJson method. I'm making one of the polygons editable. I want to add a listener when a vertice is edited/added.
If I had used the Polygon class, I could have added the listener set_at
to its path(s), according to the documentation:
The listener must be set on the polygon's path. If the polygon has multiple paths, a listener must be set on each path.
Which means that in the Polygon class it can be done like this:
let polygon = new google.maps.Polygon({ ...options here ...})
let outerPath = polygon.getPath();
google.maps.event.addListener(outerPath, 'set_at', function() {
console.log('Vertex moved on outer path.');
});
However, when the polygons are loaded using loadGeoJson, they are considered as features in the Data layer, but the Data.Feature class does not have a getPath method. How can I add the set_at
listener to a Polygon in the Data.Feature class?
The geojson that is being loaded looks like this:
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"name":"Test zone"},"geometry":{"type":"Polygon","coordinates":[[[28.29,70.46],[28.34,70.45],[28.37,70.47]]]},"id":"10"}]}