简体   繁体   中英

Google Maps API V3 - Drawing manager event listeners are fired multiple times

I am using Google maps api v3. I have a drawing manager class event listener as follows

 google.maps.event.addListener(drawingManager, 'polylinecomplete', function(polyline) {
      var val = (polyline.getPath().getArray());

   });

but the problem is this event is triggered multiple times. Is there any way around this. I want an even which is fired only once after drawing is complete.

You probably registered the event listener multiple times.

The polylinecomplete listener is fired when a polyline is completed. The only way the event is triggered multiple times is when you have registered more of such listeners.

Whenever you call google.maps.event.addListener() a new listener is registered. Check where where the listener registration code is placed and how many times its called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM