views:

76

answers:

1

I have JSON objects returning form the server and markers created for them. On the mouseover event for these marker, I need to know the ID or what index of the JSON object the clicked marker was binded from.

For eg. an array JS = {"a", "b", "c"} (cordinates ommited) was looped through and the markers were placed on the map.

If the marker 'a' was clicked. I need the event to call this function:

function doStuff(markerID){ }

markerID can either contain the array index or the ID property (which is 'a').

+2  A: 
for (var i in markers) {
   ...

   (function (marker) {
     GEvent.addListener (marker, "click", function () {
       doStuff (marker);
     );
   }) (markers[i]);
}

Calls to doStuff should receive the appropriate marker object.

Hans B PUFAL