-1

I want to prevent my GMaps object from adding unneeded listeners.

var map = new google.maps.Map(mapWrapperElem, mapOptions);
map.addListener("click",function(event){
    // Do stuff
});

How do I prevent map from adding a "click" listener if there's already a "click" listener on it?

Username
  • 3,463
  • 11
  • 68
  • 111
  • Duplicate of [How to check whether dynamically attached event listener exists or not?](https://stackoverflow.com/a/47414605/7138697) – geocodezip Mar 20 '18 at 13:47

1 Answers1

1

This cannot be achieved. There is not way to detect if there is an event listener added or not.

There is a rather complex method of doing it:

See: https://stackoverflow.com/a/47414605/7138697