开发者

Google Maps, Multiple XML, Show on click via Javascript (I guess...)

spent already many hours of research, but I'm still stuck...

I want to have a google map. On this map are markers which come from a xml file. So far no problem,开发者_JAVA技巧 but what I want now is to display markers coming from multiple xml files. So lets say I have markers1.xml and markers2.xml, then I want to have checkboxes on google maps and turn on/off markers1 or markers2 or both and they are displayed accordingly...

I know that must be possible since I remember I saw it on websites before... If someone got a link with information how to build something like this, that would be of great help already...thanks!


Have a look at the Overlays documentation: http://code.google.com/apis/maps/documentation/javascript/overlays.html#OverlaysOverview

// gmap instance
var map = new google.maps.Map( ...;

// add markers to separate arrays
var markers1 = [];
var markets2 = [];

for (var m in markers1) {
    markers1[m].setMap(null); // setting map to null removes markers from map
}
for (var m in markers2) {
    markers2[m].setMap(map);  // setting map adds markers from map
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜