I have a function getLocation like this in my map.ts:
let location = this.geocoderService.getLocation(this.callbackPosition);
//Here do I want to wait for the location to use it in the setView method
if (location.length) {
this.map.setView(location, 14);
let toast = this.toastCtrl.create({
message: 'Location was change successfully',
duration: 3000,
position: 'bottom',
closeButtonText: 'OK',
showCloseButton: true
});
toast.present();
}
And in the geoCoderService I have the getLocation method:
getLocation(callback) {
let position = [
this.lat,
this.lng
]
callback(position);
}
But how do I use the callback to return the position so the initializing of the map wait for the position