Hi,
I am trying to catch the click event whenever the user clicks on a Marker in InMemoryMarkerOverlay. I have tried to use the code that is suggested for SimpleMarkerOverlay.
var OnMapCreated = function ( map ) {
var markerOverlay = map.getLayer('InMemoryMarkerOverlayId');
for (var i in markerOverlay.markers) {
var marker = markerOverlay.markers[i];
marker.events.register('click', marker, function (evt) {
var id = this.id;
alert(id);
});
}
}
I tested this using both SimpleMarkerOverlay and InmemoryMarkerOverlay. It works fine with Simple but not with InMemory(script is placed at the end of body tag). The reason is OnMapCreate gets called before the Markers are added to the overlay while using InMemory. I guess it is because of the dynamic Ajax optimization of the InMemoryMarkerOverlay. So I tried registering the click events manually after page load and it worked but this time when the user drags the map or uses zoom the markers are not clickable anymore(again probably because of Ajax modifies markers?).
I wanted to use InMemoryMarkerOverlay because of performance but it looks like it is going to create a lot of problems for me since my work includes lots of click events. Is there a workaround for this or should I switch to SimpleMarkerOverlay?
Thanks.