Search code examples
androidiosionic-framework

Using coordinates in Ionic LaunchNavigator.navigate instead of city text


I'm trying to load a navigator app from my Ionic application to show directions and I am using Google Maps, but the problem is that I am using the launchNavigator function which only accepts a string - the name of the location.

navigateLocation(){
    let options: LaunchNavigatorOptions = {
        start:[this.latitude,this.longitude],
        app: this.launchNavigator.APP.GOOGLE_MAPS
    };
    this.launchNavigator.navigate('Lagos, ON', options)  //here
    .then(success =>{
        console.log(success);
    },error=>{
        console.log(error);
    })
}

So the Lagos option, could be London, or any other city, but what if I'm trying to get a remote location, or some other city. Why can't I just use the longitude and latitude, instead of the name? For example

this.launchNavigator.navigate({lat:8.234345, lng:7:5644563}, 'ON', options);

...something similar to that. What can I try next?


Solution

  • I use it like this let destination = [lat, lng]; this.launchNavigator.navigate(destination) .then( success => console.log('Launched navigator'), error => console.log('Error launching navigator', error) );

    And it shows me how do i go from where I am to the coordinates I pass.