项目
在 GitHub 查看
arunisrael/angularjs-geolocation
关于
An angular.js wrapper around window.navigator.geolocation
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文AngularJS-Geolocation
An angular.js wrapper around window.navigator.geolocation
Bower
This module is available as bower package, install it with this command:
bower install angularjs-geolocation
or
bower install git://github.com/arunisrael/angularjs-geolocation.git
Usage
- Add the geolocation module as dependency
- Inject the geolocation service (yes, it has the same name)
- Invoke the getLocation method on the geolocation service to retrieve a promise
- The promise will be resolved with the position returned by window.navigator.getCurrentPosition if the user allows the browser to access their location
- The promise will be rejected if the user rejects location access or the browser does not support it
Example
angular.module('barterApp',['geolocation'])
.controller('geoCtrl', function ($scope,geolocation) {
geolocation.getLocation().then(function(data){
$scope.coords = {lat:data.coords.latitude, long:data.coords.longitude};
});
});
Demo
See this plunker that displays your latitude/longitude
Error Handling
The geolocation module defines a geolocation-msgs constant holding error msgs that are broadcast if the user rejects location access:
$rootScope.$broadcast('error',CONSTANTS['errors.location.notFound']);
or if the browser does not support geolocation:
$rootScope.$broadcast('error',geolocation_msgs['errors.location.unsupportedBrowser']);
Testing
grunt test
License
探索相关项目
加载中…