使用当前用户的位置和餐馆位置(地理坐标),用户可以点击链接打开Google地图并获取指向所需位置的路线。然而,当我使用Android的后退按钮时,它无法返回到应用程序,然后应用程序“卡在”Google地图中,而无法在应用程序中浏览。我该如何解决这个问题? - 使用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>
答案 0 :(得分:0)
找到了解决方案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>