【发布时间】:2013-05-21 09:04:22
【问题描述】:
我正在尝试从 Google 地图中清除之前的路线。但是,当您进行另一次搜索时,前一次搜索中的折线和标记仍会显示。我尝试过使用directionsRenderer.setMap(null),但它没有任何区别。任何想法我做错了什么?
(function () {
Maps.Directions = function(googleMap, data, options) {
var directionsService = new google.maps.DirectionsService(),
directionsRenderer = new google.maps.DirectionsRenderer();
function getDirections() {
directionsService.route(data.request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsRenderer.setDirections(response);
}
});
}
directionsRenderer.setMap(null);
directionsRenderer.setMap(googleMap);
getDirections();
};
})();
【问题讨论】:
标签: javascript google-maps google-maps-api-3