【问题标题】:Ionic cannot open map app via ngHref on iOSIonic 无法在 iOS 上通过 ngHref 打开地图应用
【发布时间】:2015-12-28 10:08:06
【问题描述】:

我正在尝试在我的应用程序中创建一个地图链接,当用户单击它时,它将在 iOS 上打开本机地图应用程序。当我的代码看起来像 href="maps://maps.apple.com/?ll=1.5149818510303,110.35436153412" 时,它就可以工作了。但是,当我输入ng-href="maps://maps.apple.com/?ll=1.5149818510303,110.35436153412" 时,XCode 上会显示Failed to load webpage with error: The URL can’t be shown 错误。

我该如何解决?

【问题讨论】:

    标签: ios angularjs cordova ionic-framework


    【解决方案1】:

    我用它在我的 ionic 应用程序上打开地图应用程序:

    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:

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

    而且效果很好。

    【讨论】:

      猜你喜欢
      • 2019-07-17
      • 2017-03-04
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 2015-12-23
      • 1970-01-01
      • 2013-03-07
      • 2013-10-29
      相关资源
      最近更新 更多