简体   繁体   中英

Ionic 3 - How to open external native map in android?

I've searched everywhere and anybody seems to have the same problem. My need is to navigate to external native map (Google Maps or Apple Maps). To do this i'm using InAppBrowser with the following code:

if(this.platform.is('ios')){
  const browser = this.iab.create('maps://?q=' + destination, '_system', 'location=yes');
}
else{
  const browser = this.iab.create('geo:0,0?q=' + destination, '_system');        
}

…and it works only on iOS. With ionic-v1 i've always used this way and it has always worked on both platforms.

Now, on android, when execute the command, it effectively opens BUT when i try to return on my application i see a white screen with “Cannot find /undefined” or an error page like the following.

ErrorPage

To me seems like InAppBrowser try to do a navigation to geo, that ionic doesn't find.

The weird thing is that with “tel” “mail” and other commands it works without problem.

I cannot understand where the problem effectively is.

I've already tried LaunchNavigator and the result is the same as InAppBrowser.

I leave some info about what version i'm using.

cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
@ionic-native/in-app-browser@^3.14.0

cli packages:

  @ionic/cli-utils  : 1.9.2
  ionic (Ionic CLI) : 3.9.2

global packages:

  Cordova CLI : 6.5.0

local packages:

  @ionic/app-scripts : 1.3.12
  Cordova Platforms  : android 6.1.2 ios 4.3.1
  Ionic Framework    : ionic-angular 3.6.0

System:

  ios-deploy : 1.9.0
  ios-sim    : 5.0.11
  Node       : v6.10.3
  npm        : 3.10.10
  OS         : macOS Sierra
  Xcode      : Xcode 8.3.3 Build version 8E3004b

Thank you in advance for your help!

Use this, https://ionicframework.com/docs/native/launch-navigator/

lunchNavigator(lati: any, lngti: any) {
        let options: LaunchNavigatorOptions = {
            // app: LaunchNavigator.APPS.USER_SELECT

        };

        this.launchNavigator.navigate([parseFloat(lati), parseFloat(lngti)], options)
        .then(
            success => console.log('Launched navigator'),
            error => console.log('Error launching navigator', error)
        );
    }

The reason why anyone has my problem is because i've done a huge error in html.

I was calling two function with two different click event on the same button. A mistake that i didn't notice at all until now.

The good news is that i solve my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM