【发布时间】:2015-01-21 14:09:15
【问题描述】:
我正在为我正在构建的项目使用 Google Maps API v3。我已经设法在地图上用户单击的位置放置标记,但是我希望有一个清除所有按钮来删除所有标记。我在这里查看了各种答案并尝试了不同的方法。我还查阅了 Google Maps API 文档,但是我尝试过的所有方法都不起作用。需要注意的是,地图可以有多个标记。
我的代码如下:
///The function addLatLng is called when the user clicks on the Map
function addLatLng(event) {
// This code adds the marker to the map
var marker = new google.maps.Marker({
position: event.latLng,
title: '#' + path.getLength(),
map: map
});
}
///The clearall function is called when a button is clicked
function clearall() {
poly.setMap(null);//This clears the polyline that is drawn and works correctly
}
任何帮助将不胜感激
【问题讨论】:
标签: javascript api google-maps google-maps-api-3