已经在这方面工作了一个星期,可以做一些指导:
需要使用两列复选框来过滤地图上的标记
第1列是:data.ConType
第2列是:data.Operator
我需要它来检查复选框并仅返回符合两个选中框列标准的标记。
我已经让它在第一栏上工作并尝试使用&&函数让它读取第二个并匹配,但到目前为止它不起作用 这是show函数的工作部分:
// === Store the category and name info as a marker properties ===
marker.mycategory = data.ConType;
marker.myname = data.Name;
marker.myoperator = data.Operator,
gmarkers.push(marker);
// end Looping through the JSON data
<!-- Map traffic begin -->
(function (marker, data) {
// Attaching a click event to the current marker
google.maps.event.addListener(marker, 'click', function(e) {}); // end Attaching a click event to the current marker
})(marker, data); // end Creating a closure
}
} // end of initialize function
// == shows all markers of a particular category, and ensures the checkbox is checked ==
function show(category) {
for (var i=0; i<gmarkers.length; i++) {
if (gmarkers[i].mycategory == category) {
gmarkers[i].setVisible(true);
}
}
// == check the checkbox ==
document.getElementById(category+"box").checked = true;
}
// == hides all markers of a particular category, and ensures the checkbox is cleared ==
function hide(category) {
for (var i=0; i<gmarkers.length; i++) {
if (gmarkers[i].mycategory == category) {
gmarkers[i].setVisible(false);
}
}
// == clear the checkbox ==
document.getElementById(category+"box").checked = false;
// == close the info window, in case its open on a marker that we just hid
infoBubble.close();
}
// == a checkbox has been clicked ==
function boxclick(box,category) {
if (box.checked) {
show(category);
} else {
hide(category);
}
// == rebuild the side bar
makeSidebar();
}
function myclick(i) {
google.maps.event.trigger(gmarkers[i],"click");
}
有没有人有这样的工作标准的指针或工作网页/ jsfiddle / GitHub?