Permalink
Browse files

Add , remove direct navigator access. Add msg constants

  • Loading branch information...
mikepugh committed Feb 3, 2014
1 parent c81868d commit caeae92b44d7f0f236ef1b9229344efbbd6a6939
Showing with 39 additions and 31 deletions.
  1. +0 −8 Gruntfile.js
  2. +1 −1 bower.json
  3. +18 −10 dist/angulargeo.js
  4. +1 −1 dist/angulargeo.min.js
  5. +1 −1 package.json
  6. +18 −10 scripts/angulargeo.js
View
@@ -151,14 +151,6 @@ module.exports = function (grunt) {
src: [
'**/*.js'
]
- },
- {
- expand: true,
- cwd: '.tmp/images',
- dest: '<%= yeoman.dist %>/images',
- src: [
- 'generated/*'
- ]
}
]
}
View
@@ -1,6 +1,6 @@
{
"name": "AngularGeo",
- "version": "0.1.0",
+ "version": "0.2.0",
"homepage": "https://github.com/mikepugh/AngularGeo",
"authors": [
"Mike Pugh <mikepugh82@gmail.com>"
View
@@ -6,12 +6,17 @@
"use strict";
var angularGeo = angular.module('angular-geo', []);
+ angularGeo.constant('angularGeo_msgs', {
+ 'errors.unsupportedBrowser':'Browser geolocation not supported',
+ 'errors.noServices':'angularGeo could not locate any of the geo providers specified, verify that you have them properly linked',
+ 'errors.noProviders':'angularGeo requires at least one geo provider'
+ });
angularGeo.provider('angularGeo', function() {
var $$geoConfig = {
providerSvcNames: [],
providers: []
};
- var $$supportsGeolocation = 'geolocation' in navigator;
+ var $$supportsGeolocation = false;
var $$watchId;
var $$currentProvider = 0;
@@ -20,9 +25,12 @@
$$geoConfig.providerSvcNames.push(providerSvcName);
return this;
},
- $get: function ($log, $q, $timeout, $rootScope, $injector) {
+ $get: function ($log, $q, $timeout, $rootScope, $injector, $window, angularGeo_msgs) {
+
+ $$supportsGeolocation = 'geolocation' in $window.navigator;
+
if($$geoConfig.providerSvcNames.length === 0) {
- throw new Error("AngularGeo requires at least 1 geo provider");
+ throw new Error(angularGeo_msgs.errors.noProviders);
}
// Instantiate the geo providers and store them within the $$geoConfig object
for(var i = 0; i < $$geoConfig.providerSvcNames.length; i++) {
@@ -34,7 +42,7 @@
}
var $$providers = $$geoConfig.providers;
if($$providers.length === 0) {
- throw new Error('angularGeo could not locate any of the geo providers specified, verify that you have them properly linked');
+ throw new Error(angularGeo_msgs.errors.noServices);
}
var $$geocode = function(address, bounds, region, restrictions, filters, promise) {
@@ -64,10 +72,10 @@
getCurrentPosition: function(options, autoReverseGeocode) {
var self = this;
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
var deferred = $q.defer();
- navigator.geolocation.getCurrentPosition(function(pos) {
+ $window.navigator.geolocation.getCurrentPosition(function(pos) {
if(autoReverseGeocode) {
var p = self.reverseGeocode({latitude: pos.coords.latitude, longitude: pos.coords.longitude}, null, null, null, null);
p.then(function(results) {
@@ -85,10 +93,10 @@
watchPosition: function(options) {
var self = this;
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
var deferred = $q.defer();
- $$watchId = navigator.geolocation.watchPosition(function(pos) {
+ $$watchId = $window.navigator.geolocation.watchPosition(function(pos) {
$rootScope.$broadcast("angulargeo:watchposition", pos);
}, function(err) {
deferred.reject(err);
@@ -98,9 +106,9 @@
},
clearWatch: function() {
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
- navigator.geolocation.clearWatch($$watchId);
+ $window.navigator.geolocation.clearWatch($$watchId);
}
}
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "AngularGeo",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "AngularGeo\r ==========",
"main": "angulargeo.js",
"scripts": {
View
@@ -6,12 +6,17 @@
"use strict";
var angularGeo = angular.module('angular-geo', []);
+ angularGeo.constant('angularGeo_msgs', {
+ 'errors.unsupportedBrowser':'Browser geolocation not supported',
+ 'errors.noServices':'angularGeo could not locate any of the geo providers specified, verify that you have them properly linked',
+ 'errors.noProviders':'angularGeo requires at least one geo provider'
+ });
angularGeo.provider('angularGeo', function() {
var $$geoConfig = {
providerSvcNames: [],
providers: []
};
- var $$supportsGeolocation = 'geolocation' in navigator;
+ var $$supportsGeolocation = false;
var $$watchId;
var $$currentProvider = 0;
@@ -20,9 +25,12 @@
$$geoConfig.providerSvcNames.push(providerSvcName);
return this;
},
- $get: function ($log, $q, $timeout, $rootScope, $injector) {
+ $get: function ($log, $q, $timeout, $rootScope, $injector, $window, angularGeo_msgs) {
+
+ $$supportsGeolocation = 'geolocation' in $window.navigator;
+
if($$geoConfig.providerSvcNames.length === 0) {
- throw new Error("AngularGeo requires at least 1 geo provider");
+ throw new Error(angularGeo_msgs.errors.noProviders);
}
// Instantiate the geo providers and store them within the $$geoConfig object
for(var i = 0; i < $$geoConfig.providerSvcNames.length; i++) {
@@ -34,7 +42,7 @@
}
var $$providers = $$geoConfig.providers;
if($$providers.length === 0) {
- throw new Error('angularGeo could not locate any of the geo providers specified, verify that you have them properly linked');
+ throw new Error(angularGeo_msgs.errors.noServices);
}
var $$geocode = function(address, bounds, region, restrictions, filters, promise) {
@@ -64,10 +72,10 @@
getCurrentPosition: function(options, autoReverseGeocode) {
var self = this;
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
var deferred = $q.defer();
- navigator.geolocation.getCurrentPosition(function(pos) {
+ $window.navigator.geolocation.getCurrentPosition(function(pos) {
if(autoReverseGeocode) {
var p = self.reverseGeocode({latitude: pos.coords.latitude, longitude: pos.coords.longitude}, null, null, null, null);
p.then(function(results) {
@@ -85,10 +93,10 @@
watchPosition: function(options) {
var self = this;
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
var deferred = $q.defer();
- $$watchId = navigator.geolocation.watchPosition(function(pos) {
+ $$watchId = $window.navigator.geolocation.watchPosition(function(pos) {
$rootScope.$broadcast("angulargeo:watchposition", pos);
}, function(err) {
deferred.reject(err);
@@ -98,9 +106,9 @@
},
clearWatch: function() {
if(!$$supportsGeolocation) {
- throw new Error("Browser geolocation not supported");
+ throw new Error(angularGeo_msgs.errors.unsupportedBrowser);
}
- navigator.geolocation.clearWatch($$watchId);
+ $window.navigator.geolocation.clearWatch($$watchId);
}
}
}

0 comments on commit caeae92

Please sign in to comment.