複数のルートを読み込むと、前のルートは削除されません。 多くの人がdirectionsDisplay.setMap
をnull
に設定すると言いましたが、それは動作しません。 ルートは地図上にあり、directionsDisplay
にはないようです。 これは動作しません私のコードです:google.mapでルートをクリアするにはどうすればよいですか?
NgMap.getMap('mapShop').then(function(map) {
$scope.googleMaps = map;
var directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
directionsDisplay.setMap(null);
directionsDisplay.setDirections(null);
directionsDisplay.setMap($scope.googleMaps);
// get geolocation for center map and marker
NavigatorGeolocation.getCurrentPosition().then(function(position) {
$scope.latitude = $routeParams.latitude;
$scope.longitude = $routeParams.longitude;
$scope.urlLocalCard = "http://maps.apple.com/?daddr=" + $routeParams.latitude + "," + $routeParams.longitude + "&saddr=" + position.coords.latitude + "," + position.coords.longitude + "&ll=" + $routeParams.latitude + "," + $routeParams.longitude + "&z=10&t=s";
var request = {
origin: position.coords.latitude + ',' + position.coords.longitude,
destination: $routeParams.latitude + ',' + $routeParams.longitude,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
alert('Google route unsuccesfull!');
}
});
});
JSコンソールにはどのようなエラーがありますか? –
コンソールにエラーが表示されます。 –
それはどういう意味ですか? –