1.0.0 • Published 8 years ago

ngCurrentGeolocation v1.0.0

Weekly downloads
3
License
-
Repository
github
Last release
8 years ago

ngCurrentGeolocation

Receiving geolocation information from modern web browsers (AngularJS apps)

Installation

npm install ngCurrentGeolocation

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
    <script src="ngGeolocation.js"></script>
    <script>
        var app = angular.module('myApp', ['geolocation']);
        app.controller('MyCtrl', ['$scope', 'geolocation', function($scope, geolocation) {
            var geoObj = new geolocation;
            geoObj.getLocation().then(function(data) {
                $scope.coords = {lat: data.coords.latitude, lon: data.coords.longitude};
            });
        }]);
    </script>
</head>
<body ng-app="myApp">
    <div ng-controller="MyCtrl">
        Coords: {{coords.lat}}, {{coords.lon}}
    </div>
</body>
</html>