我对使用Google地图API非常陌生,我想知道如何添加一个复选框过滤器来显示地图上的某些标记。以下是我到目前为止的情况:
var icons = ['green-dot.png','red-dot.png','blue-dot.png','orange- dot.png','yellow-dot.png'];
var map = new google.maps.Map(document.getElementById('map'),{
zoom: 2,
center: new google.maps.LatLng(47.025210,2.573184),
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
streetViewControl: false,
panControl: false,
zoomControlOptions:{position:google.maps.ControlPosition.LEFT_BOTTOM}});
var infowindow = new google.maps.InfoWindow({maxWidth: 160});
var markers = new Array();
for (var i = 0; i < locations.length; i++){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][2], locations[i][3]),
map: map,
title: locations[i][0],
icon: 'http://maps.google.com/mapfiles/ms/icons/' + icons[locations[i][4]]});
markers.push(marker);
google.maps.event.addListener(marker, 'mouseover', (function(marker, i){
var contentString = locations[i][1];
return function(){
infowindow.setContent(contentString);
infowindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function(){
window.location.href= locations[i][5];
});
}
})(marker, i));
}
我不知道如何继续使用复选框过滤器。