I'm trying to implement Azure Maps and I'm running into an issue. I'm creating and removing layers at run time, and every time I set a new layer I add the event 'mouseup' on that layer to be able to click on markers, like this:
map.events.add('mouseup', layer, this.onMarkerClick);
When I switch layers, I try to remove the events like this:
map.events.remove('mouseup', layer, this.onMarkerClick);
But when this line is called, nothing seems to happen and the event callback keeps being called when I click a marker. This means that, after switching layers a few times, the onMarkerClick callback gets called multiple times per click.
I tried calling map.events.remove in multiple location in the code, before and after removing the layer itself. Saving the layer to a property and using that in the remove function. Saving the ID in a string property and using it the get the layer from the map and then using that in the remove function. None seemed to work, no matter how I call map.events.remove, the event keeps getting triggered.
Does anyone know what to do? I've tried looking for code examples of maps.events.remove being used for a situation similar to mine but I can't seem to find any...