Socket
Socket
Sign inDemoInstall

angularjs-geolocation

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angularjs-geolocation

AngularJS-Geolocation =========


Version published
Maintainers
1
Install size
1.00 MB
Created

Readme

Source

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

The MIT License

FAQs

Last updated on 16 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc