Polygon editing event of Google Maps api v3 does not start in all handles

I have a drawManager that allows the user to draw a polygon. When the user draws this polygon, I calculated the area of ​​this polygon. All this works fine, except for editing polygon event handling. I am using the following code

google.maps.event.addListener(path, "set_at", function(){ //my code here }); 

So, this kind of work, but only works for the "corners" of the polygon. There are intermediate, barely noticeable editing knobs (squares) between the main white knobs. If I edit the polygon by pulling one of these knobs, the event does not fire.

Any ideas on this behavior? Is this an alleged or some kind of bug with api or my code?

Thanks for any help.

Greg

+6
source share
1 answer

The set_at event is fired when updating LatLng on the way. This happens when you move those existing square nodes (by changing the LatLng of this node). The “slightly gray squares” at the edges of the overlays allow the user to add new paths to the path rather than edit existing ones (you will notice that you move the gray node to create a different angle). In this case, add an eventListener for "insert_at" instead of "set_at" to handle when new LatLngs are added to the shapes path.

+9
source

Source: https://habr.com/ru/post/912428/


All Articles