如何在google-maps-v3上获取所有标记 [英] how to get all markers on google-maps-v3
本文介绍了如何在google-maps-v3上获取所有标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在Google Maps上获得所有的标记? 如果你的意思是我怎么能得到一个参考给定地图上的所有标记 - 然后我认为答案是对不起,你必须自己做。我不认为有任何方便的maps.getMarkers()类型的函数:你必须保持自己的引用,因为点创建:
var allMarkers = [];
....
//为(var i = 0; i <10; i ++)创建一些标记
{
var marker = new google.maps.Marker {...});
allMarkers.push(marker);
}
...
然后你可以遍历 allMarkers
数组,并做任何你需要做的事情。
Is there a way to get all the markers on Google Maps?
解决方案
If you mean "how can I get a reference to all markers on a given map" - then I think the answer is "Sorry, you have to do it yourself". I don't think there is any handy "maps.getMarkers()" type function: you have to keep your own references as the points are created:
var allMarkers = [];
....
// Create some markers
for(var i = 0; i < 10; i++) {
var marker = new google.maps.Marker({...});
allMarkers.push(marker);
}
...
Then you can loop over the allMarkers
array to and do whatever you need to do.
这篇关于如何在google-maps-v3上获取所有标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文