Ionic 2 Download map "Incomprehensible (in promise): [object PositionError]"
initMap(): Promise<any> {
this.mapInitialised = true;//part 1
return new Promise((resolve) => {
this.geolocation.getCurrentPosition().then((position) => {// Part 2
let latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement, mapOptions);
resolve(true);
});
});
}
You need to catch a mistake and do something with it. To do this, add an error. The code to fix your problem is here:
initMap(): Promise<any> {
this.mapInitialised = true;//part 1
return new Promise((resolve) => {
this.geolocation.getCurrentPosition().then(
(position) => {// Part 2
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP;
}
this.map = new google.maps.Map(this.mapElement, mapOptions);
resolve(true);
},
// Here is the error catching that needs to be added
err =>{
console.log(' Error : ' + JSON.stringify(error));
});
});
}