Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove marker listeners

somewhat simple problem(to explain) this time:

i have an array of markers that i equip with eventlisteners thusly:

for (i in markersArray) {
google.maps.event.addListener(markersArray[i], 'click', function() {        
    //stuff it does
    google.maps.event.removeListener(?????)     //remove self... but HOW?!
});}

as i mention in the comment, i simply want the listener to be removed once it is clicked.

problem is that i dont know what the handle for the listener is.

like image 570
Stjerneklar Avatar asked Jul 20 '10 12:07

Stjerneklar


People also ask

How do you remove marker from maps?

Click the marker to reveal the editing options. Click the "Delete" link in the lower-left corner of the dialog box.

How do I remove a marker from Google Maps API?

To remove a marker from the map, call the setMap() method passing null as the argument. marker. setMap(null);

How many markers can be created if maps are generated by the Google wizard?

The use of markers in the map is quite limited but you can put up to 50 markers on a map in 10 different colors and in 3 different sizes with an optional letter in it on the map.


1 Answers

You can use the "addListenerOnce". Then you don't even have to bother with removing the listener.

addListenerOnce(instance:Object, eventName:string, handler:Function)

Like event.AddListener, but the handler removes itself after handling the first event.

like image 102
CrazyEnigma Avatar answered Sep 29 '22 07:09

CrazyEnigma