ios - Angularjs: linking to phone's mapping app -


i have webapp wants offload walking / driving directions phone's native apps. google maps app , maps.apple.com android , ios respectively. can detect phone user agent presumably, can't work out how configure link.

<li><a href ng-click="geohandler()"> directions</a></li> 

this have in relevant controller.

$scope.geohandler = function() {     // user agent sniffing here     var path = "geo:0,0?q="+$scope.resto.lat+","+$scope.resto.lng+"("+$scope.resto.rname+")";     // var path = http://maps.apple.com/?ll=$scope.resto.lat+","+$scope.resto.lng     return $location.path(path); } 

when had geo link href in html, phone did right thing, code taking me home page of spa.

so, questions are:

  • is ng-click right way go (i can't use function ng-href think);

  • how launch intent via $location?

ok, moved different , simpler approach. not sure whether elegant, works.

view

<a ng-href="{{geopath}}">directions</a> 

controller

if ( /iphone/.test(navigator.useragent))     path = "http://maps.apple.com/?ll="+$scope.resto.lat+","+$scope.resto.lng"; else path = "geo:0,0?q="+$scope.resto.lat+","+$scope.resto.lng+"("+$scope.resto.rname+")"; $scope.geopath = path; 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -