I have JSON objects returning form the server and markers created for them. On the mouseover event for these marker, I need t开发者_Go百科o 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').
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.
精彩评论