在此代码中,我尝试添加direction
:
public directionsService : any; //= new google.maps.DirectionsService;
public directionsDisplay : any;// = new google.maps.DirectionsRenderer;
:
:
:
initializeMap() {
this.directionsService = new google.maps.DirectionsService;
this.directionsDisplay = new google.maps.DirectionsRenderer;
let minZoomLevel = 14;
Geolocation.getCurrentPosition().then((position) => {
this.map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel,
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
mapTypeControl: false,
streetViewControl: false,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(this.map);
});
this.directionsDisplay.setMap(this.map);
:
:
:
:
calculateAndDisplayRoute(directionsService, directionsDisplay) {
origin
console.log('here Iam');
directionsService.route({
origin: ,
destination: this.tLastLat+','+this.tLastLng,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}