我有任意数量的谷歌地图标记。我正在遍历它们并添加事件侦听器:
for ( i in markers )
{
google.maps.event.addListener(markers[i], 'dragend', function()
{
console.log( this ); //<-- this doesn't work
}
}
使用this
似乎不起作用。也试过:
for ( i in markers )
{
google.maps.event.addListener(markers[i], 'dragend', function()
{
console.log( markers[i] ); //<-- this doesn't work either
}
}
如何访问触发事件的相对标记对象?