【问题标题】:External link to Google Map direction, back to app does not work指向谷歌地图方向的外部链接,返回应用程序不起作用
【发布时间】:2015-04-13 18:08:46
【问题描述】:

使用当前用户的位置和餐厅位置(地理坐标),用户可以点击链接打开 Google 地图并获取前往所需地点的路线。但是,当我使用 Android 的后退按钮时,它无法返回应用程序,然后应用程序“卡”在谷歌地图中,​​无法在应用程序中浏览回来。我该如何解决这个问题? - 使用 AngularJS 和 Ionic。

这是 hTML:

<ion-list>
  <ion-item  ng-controller="loadingCtrl" bindonce  ng-repeat= "restaurant in restaurantList | orderBy: 'distance' " href="#">

    <article class="item_frame">
        <div class="marker_left_container">
            <img  class="venue_rest_marker" ng-src="{{restaurant.icon}}">   
            <span class="venu_type_text">{{restaurant.venueType}}</span>
            <span class="distance_from_user_rest"> {{distanceTo(restaurant)}} km</span>
            <span class="distance_from_user_rest2">from current location</span>
        </div>
        <div class="restaurant_details_container">
            <h1 class="restaurant_name_inlist">{{restaurant.Name}}</h1>
            <span class="restaurant_detail_inlist2">{{restaurant.subCuisine}}<br> {{restaurant.subsubCuisine}}</span>
            <span class="restaurant_address">{{restaurant.address}}, <br> </span>
            <span class="restaurant_address">{{restaurant.cp}}, {{restaurant.city}} <br><br></span>
            <span class="restaurant_others">{{restaurant.phoneNumber}}<br> </span>
            <span class="restaurant_others">{{restaurant.website}}<br> <br></span>   
            <div class="get_dir_container"><a href="https://www.google.com/maps/dir//{{restaurant.lat}},{{restaurant.long}}/">
                <img src="img/get_direction_v3.png" class="get_dir_icon">
                <span class="get_dir_text">Get direction on Google Maps</span>
            </a></div>
        </div>

    </article><!--main article frame 1 -->  

  </ion-item>
</ion-list>

【问题讨论】:

    标签: angularjs ionic-framework


    【解决方案1】:

    找到解决方案here

    .directive('browseTo', function ($ionicGesture) {
    return {
     restrict: 'A',
     link: function ($scope, $element, $attrs) {
      var handleTap = function (e) {
      // todo: capture Google Analytics here
      var inAppBrowser = window.open(encodeURI($attrs.browseTo), '_system');
      };
       var tapGesture = $ionicGesture.on('tap', handleTap, $element);
      $scope.$on('$destroy', function () {
       // Clean up - unbind drag gesture handler
      $ionicGesture.off(tapGesture, 'tap', handleTap);
     });
    }
    }
    });
    

    在 HTML 中:

    <button browse-to="https://www.google.com">Open Google</button>
    

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多