I'm trying to display the route, currentlocation
from another location, in the browser, works but when I try in the phone it seems doesn't work.
I mean the center map doest work and the routes don't display
sorry for my bad English:(
ngOnInit() {
this.loadMap();
}
loadMap() {
try {
this.map = new google.maps.Map(document.getElementById("map"), {
zoom: 7,
center: { lat: 41.85, lng: -87.65 }
});
} catch (e) {
window.alert("No CurrentLocation " + e);
}
this.directionsRenderer.setMap(this.map);
}
//button for currentlocation
getPosition(): any {
this.geolocation.getCurrentPosition().then(resp => {
this.setCenter(resp);
});
}
setCenter(position: Geoposition) {
this.myLatLng = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
this.map.setCenter(this.myLatLng);
}
calculateAndDisplayRoute(destination): void {
var t = this;
this.directionsService.route(
{
origin: t.myLatLng,
destination: t.destination.text,
travelMode: "DRIVING"
},
(response, status) => {
if (status === "OK") {
this.directionsRenderer.setDirections(response);
} else {
window.alert("Directions request failed due to " + status);
}
}
);
}