有没有办法用 jQuery 过滤谷歌地图位置变量?
前任:
单击带有 ID car 的链接,过滤所有带有 ID car 的字符串。点击 ID car 会隐藏地图上带有 ID 船的所有字符串,并在地图上只显示带有 ID car 的字符串。
可能吗?
function initialize() {
var locations = [
['<strong>Firm 1</strong><br />1111 Country<br />Street<br /><br />', 47.6801806,8.7499505, 1, id car here?? ],
['<strong>Firm 2</strong><br />2222 Country<br />Street<br /><br />', 47.6801806,8.7499505, 2, id boat here?? ],
];
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 10,
center: new google.maps.LatLng(47.603786, 9.055737),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: new google.maps.MarkerImage('/assets/templates/style/images/iconKarte.png')
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
}
</script>
<div id="map_canvas" style="width:750px;height:500px;"></div>