我已尝试在此处查看各种代码块以及Google Maps API文档,但STILL尚无法弄清楚如何隐藏标记.
这是我正在使用的当前代码,它适用于一个实例.一旦我在带有markers.setMap(null)的函数中添加了"for"循环,Firefox就会显示以下错误:
错误:TypeError:markers.setMap不是函数
function removeMarkers(){
var markers;
alert(markers);
alert(locations.length);
for (i = 0; i<locations.length; i++){
markers = locations[i];
alert(markers.title);
markers.setMap(null);
}
}
Run Code Online (Sandbox Code Playgroud)