var gmarkers1 = [];
var markers1 = [];
var infowindow = new google.maps.InfoWindow({
content: ''
});
markers1 = [
['0', 'Title', 52.4357808, 4.991315699999973, 'car'],
['1', 'Title', 52.4357808, 4.981315699999973, 'third'],
['2', 'Title', 52.4555687, 5.039231599999994, 'car'],
['3', 'Title', 52.4555687, 5.029231599999994, 'second']
];
我找到了此脚本,如何将.txt文件中的数据导入markers1
?
第二,如何显示带有document.getElementById
的文本的选择?
如果我选择“汽车”以仅显示标题,则仅显示标题,如下所示:
<div id="map-canvas"></div>
<select id="type" onchange="filterMarkers(this.value);">
<option value="">Please select category</option>
<option value="second">second</option>
<option value="car">car</option>
<option value="third">third</option>
</select>
答案 0 :(得分:0)
我尝试了以下代码
filterMarkers = function (category) {
for (i = 0; i < markers1.length; i++) {
marker = gmarkers1[i];
// If is same category or category not picked
if (marker.category == category || category.length === 0) {
marker.setVisible(true);
}
// Categories don't match
else {
marker.setVisible(false);
}
document.getElementById("demo").innerHTML = "You selected: " + marker[];
}
<p id="demo"></p>
但是它让我[对象]
要阅读txt,我无法以某种方式传达。该文件将在文件服务器中
谢谢您的时间!