开发者

Google Maps:Knowing what marker the event was fired for

开发者 https://www.devze.com 2022-12-16 02:44 出处:网络
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 mar

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消