Ionic无法通过iOS上的ngHref打开地图应用程序

时间:2022-03-27 22:57:24

I am trying to do a map link in my app which when user click on it, it will open the native map app on iOS. When my code looks something like this href="maps://maps.apple.com/?ll=1.5149818510303,110.35436153412", it works. However, when I put ng-href="maps://maps.apple.com/?ll=1.5149818510303,110.35436153412", I will get Failed to load webpage with error: The URL can’t be shown error shown on XCode.

我正在尝试在我的应用程序中进行地图链接,当用户点击它时,它将在iOS上打开原生地图应用程序。当我的代码看起来像这样的href =“maps://maps.apple.com/?ll = 1.5149818510303,110.35436153412”时,它可以工作。但是,当我输入ng-href =“maps://maps.apple.com/?ll = 1.5149818510303,110.35436153412”时,我将无法加载网页并显示错误:XCode上显示的网址无法显示错误。

How can I fix it?

我该如何解决?

1 个解决方案

#1


4  

I use this to open the maps app on my ionic application:

我使用它在我的离子应用程序上打开地图应用程序:

JS:

JS:

$scope.openNavigator = function() {
  var geoString = '';

  if(ionic.Platform.isIOS()) {
    geoString = 'maps://?q='+$scope.Latitude+','+$scope.Longitude+'';
  }
  else if(ionic.Platform.isAndroid()) {
    geoString = 'geo://?q='+$scope.Latitude+','+$scope.Longitude+'';
  }
  window.open(geoString, '_system');
}

HTML:

HTML:

<div ng-click="openNavigator()">

And it works perfect.

它完美无缺。

#1


4  

I use this to open the maps app on my ionic application:

我使用它在我的离子应用程序上打开地图应用程序:

JS:

JS:

$scope.openNavigator = function() {
  var geoString = '';

  if(ionic.Platform.isIOS()) {
    geoString = 'maps://?q='+$scope.Latitude+','+$scope.Longitude+'';
  }
  else if(ionic.Platform.isAndroid()) {
    geoString = 'geo://?q='+$scope.Latitude+','+$scope.Longitude+'';
  }
  window.open(geoString, '_system');
}

HTML:

HTML:

<div ng-click="openNavigator()">

And it works perfect.

它完美无缺。