Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Showing with 83 additions and 50 deletions.
  1. +1 −3 Gruntfile.js
  2. +1 −1 bower.json
  3. +24 −2 dist/angulargeo.js
  4. +1 −1 dist/angulargeo.min.js
  5. +54 −41 dist/providers/angulargeo-google.js
  6. +1 −1 dist/providers/angulargeo-google.min.js
  7. +1 −1 package.json
View
4 Gruntfile.js
@@ -201,13 +201,11 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
- 'ngmin',
'copy:dist',
'uglify'
]);
grunt.registerTask('default', [
- 'test',
- 'serve'
+ 'build'
]);
};
View
2 bower.json
@@ -1,6 +1,6 @@
{
"name": "AngularGeo",
- "version": "0.2.0",
+ "version": "0.2.2",
"homepage": "https://github.com/mikepugh/AngularGeo",
"authors": [
"Mike Pugh <mikepugh82@gmail.com>"
View
26 dist/angulargeo.js
@@ -53,6 +53,7 @@
}, function(err) {
if($$providers.length === 1) {
deferred.reject(err);
+ return;
}
if($$currentProvider < $$providers.length - 1) {
$$currentProvider++;
@@ -64,6 +65,26 @@
return deferred.promise;
};
+ var $$reverseGeo = function(latLng, bounds, region, restrictions, filters, promise) {
+ var deferred = promise || $q.defer();
+ var p = $$providers[$$currentProvider].reverseGeocode(latLng, bounds, region, restrictions, filters);
+ p.then(function(results) {
+ deferred.resolve(results);
+ }, function(err) {
+ if($$providers.length === 1) {
+ deferred.reject(err);
+ return;
+ }
+ if($$currentProvider < $$providers.length - 1) {
+ $$currentProvider++;
+ } else {
+ $$currentProvider = 0;
+ }
+ return $$reverseGeo(latLng, bounds, region, restrictions, filters, deferred);
+ });
+ return deferred.promise;
+ };
+
return {
geocode: function(address, bounds, region, restrictions, filters) {
return $$geocode(address, bounds, region, restrictions, filters, null);
@@ -77,14 +98,15 @@
var deferred = $q.defer();
$window.navigator.geolocation.getCurrentPosition(function(pos) {
if(autoReverseGeocode) {
- var p = self.reverseGeocode({latitude: pos.coords.latitude, longitude: pos.coords.longitude}, null, null, null, null);
+ var p = $$reverseGeo({latitude: pos.coords.latitude, longitude: pos.coords.longitude}, null, null, null, null);
p.then(function(results) {
deferred.resolve(results);
}, function(err) {
deferred.reject(err);
});
+ } else {
+ deferred.resolve(pos);
}
- deferred.resolve(pos);
}, function(err) {
deferred.reject(err);
}, options);
View
2 dist/angulargeo.min.js
@@ -1 +1 @@
-(function(){"use strict";var a=angular.module("angular-geo",[]);a.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"}),a.provider("angularGeo",function(){var a,b={providerSvcNames:[],providers:[]},c=!1,d=0;return{addProvider:function(a){return b.providerSvcNames.push(a),this},$get:function(e,f,g,h,i,j,k){if(c="geolocation"in j.navigator,0===b.providerSvcNames.length)throw new Error(k.errors.noProviders);for(var l=0;l<b.providerSvcNames.length;l++)i.has(b.providerSvcNames[l])?b.providers.push(i.get(b.providerSvcNames[l])):e.error("angularGeo could not locate service "+b.providerSvcNames[l]);var m=b.providers;if(0===m.length)throw new Error(k.errors.noServices);var n=function(a,b,c,e,g,h){var i=h||f.defer(),j=m[d].geocode(a,b,c,e,g);return j.then(function(a){i.resolve(a)},function(f){return 1===m.length&&i.reject(f),d<m.length-1?d++:d=0,n(a,b,c,e,g,i)}),i.promise};return{geocode:function(a,b,c,d,e){return n(a,b,c,d,e,null)},reverseGeocode:function(){},getCurrentPosition:function(a,b){var d=this;if(!c)throw new Error(k.errors.unsupportedBrowser);var e=f.defer();return j.navigator.geolocation.getCurrentPosition(function(a){if(b){var c=d.reverseGeocode({latitude:a.coords.latitude,longitude:a.coords.longitude},null,null,null,null);c.then(function(a){e.resolve(a)},function(a){e.reject(a)})}e.resolve(a)},function(a){e.reject(a)},a),e.promise},watchPosition:function(b){if(!c)throw new Error(k.errors.unsupportedBrowser);var d=f.defer();return a=j.navigator.geolocation.watchPosition(function(a){h.$broadcast("angulargeo:watchposition",a)},function(a){d.reject(a)},b),d.promise},clearWatch:function(){if(!c)throw new Error(k.errors.unsupportedBrowser);j.navigator.geolocation.clearWatch(a)}}}}})}).call(this);
+(function(){"use strict";var a=angular.module("angular-geo",[]);a.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"}),a.provider("angularGeo",function(){var a,b={providerSvcNames:[],providers:[]},c=!1,d=0;return{addProvider:function(a){return b.providerSvcNames.push(a),this},$get:function(e,f,g,h,i,j,k){if(c="geolocation"in j.navigator,0===b.providerSvcNames.length)throw new Error(k.errors.noProviders);for(var l=0;l<b.providerSvcNames.length;l++)i.has(b.providerSvcNames[l])?b.providers.push(i.get(b.providerSvcNames[l])):e.error("angularGeo could not locate service "+b.providerSvcNames[l]);var m=b.providers;if(0===m.length)throw new Error(k.errors.noServices);var n=function(a,b,c,e,g,h){var i=h||f.defer(),j=m[d].geocode(a,b,c,e,g);return j.then(function(a){i.resolve(a)},function(f){return 1===m.length?void i.reject(f):(d<m.length-1?d++:d=0,n(a,b,c,e,g,i))}),i.promise},o=function(a,b,c,e,g,h){var i=h||f.defer(),j=m[d].reverseGeocode(a,b,c,e,g);return j.then(function(a){i.resolve(a)},function(f){return 1===m.length?void i.reject(f):(d<m.length-1?d++:d=0,o(a,b,c,e,g,i))}),i.promise};return{geocode:function(a,b,c,d,e){return n(a,b,c,d,e,null)},reverseGeocode:function(){},getCurrentPosition:function(a,b){if(!c)throw new Error(k.errors.unsupportedBrowser);var d=f.defer();return j.navigator.geolocation.getCurrentPosition(function(a){if(b){var c=o({latitude:a.coords.latitude,longitude:a.coords.longitude},null,null,null,null);c.then(function(a){d.resolve(a)},function(a){d.reject(a)})}else d.resolve(a)},function(a){d.reject(a)},a),d.promise},watchPosition:function(b){if(!c)throw new Error(k.errors.unsupportedBrowser);var d=f.defer();return a=j.navigator.geolocation.watchPosition(function(a){h.$broadcast("angulargeo:watchposition",a)},function(a){d.reject(a)},b),d.promise},clearWatch:function(){if(!c)throw new Error(k.errors.unsupportedBrowser);j.navigator.geolocation.clearWatch(a)}}}}})}).call(this);
View
95 dist/providers/angulargeo-google.js
@@ -2,48 +2,61 @@
* Created by Mike on 1/31/14.
*/
(function() {
- "use strict";
- angular.module('angular-geo-providers.google', [])
- .provider('angularGeoGoogle', function() {
- var $$q, $$log;
- var $$configuration;
+ "use strict";
+ angular.module('angular-geo-providers.google', [])
+ .provider('angularGeoGoogle', function() {
+ var $$q, $$log;
+ var $$configuration;
- if(typeof google === 'undefined' || (typeof google !== 'undefined' && typeof google.maps === 'undefined')) {
- throw new Error("Google Maps API V3 is required for angulargeo-google to function, please include it");
+ if(typeof google === 'undefined' || (typeof google !== 'undefined' && typeof google.maps === 'undefined')) {
+ throw new Error("Google Maps API V3 is required for angulargeo-google to function, please include it");
+ }
+ var $$geocoder = new google.maps.Geocoder();
+ var svc = {
+ geocode: function(address, bounds, region, restrictions, filters) {
+ var deferred = $$q.defer();
+ $$geocoder.geocode({'address': address}, function(results, status) {
+ if(status === google.maps.GeocoderStatus.OK) {
+ //todo: Normalize result set once we have a better idea what bing, etc apis return
+ deferred.resolve(results);
+ } else if(status === google.maps.GeocoderStatus.ZERO_RESULTS) {
+ deferred.resolve(null);
+ } else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
+ deferred.reject("OVER_LIMIT")
+ } else if(status === google.maps.GeocoderStatus.REQUEST_DENIED || status === google.maps.GeocoderStatus.INVALID_REQUEST) {
+ deferred.reject("FAILED");
}
- var $$geocoder = new google.maps.Geocoder();
- var svc = {
- geocode: function(address, bounds, region, restrictions, filters) {
- var deferred = $$q.defer();
- $$geocoder.geocode({'address': address}, function(results, status) {
- if(status === google.maps.GeocoderStatus.OK) {
- //todo: Normalize result set once we have a better idea what bing, etc apis return
- deferred.resolve(results);
- } else if(status === google.maps.GeocoderStatus.ZERO_RESULTS) {
- deferred.resolve(null);
- } else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
- deferred.reject("OVER_LIMIT")
- } else if(status === google.maps.GeocoderStatus.REQUEST_DENIED || status === google.maps.GeocoderStatus.INVALID_REQUEST) {
- deferred.reject("FAILED");
- }
- });
- return deferred.promise;
- },
- reverseGeocode: function(latLng, bounds, region, restrictions, filters) {
-
- }
- };
- return {
- name: 'angularGeoGoogle',
- config: function(config) {
- // do some config? set api-key?
-
- },
- $get: function($log, $q) {
- $$q = $q;
- $$log = $log;
- return svc;
- }
+ });
+ return deferred.promise;
+ },
+ reverseGeocode: function(latLng, bounds, region, restrictions, filters) {
+ var deferred = $$q.defer();
+ $$geocoder.geocode({'latLng': new google.maps.LatLng(latLng.latitude, latLng.longitude)}, function(results, status) {
+ if(status === google.maps.GeocoderStatus.OK) {
+ //todo: Normalize result set once we have a better idea what bing, etc apis return
+ deferred.resolve(results);
+ } else if(status === google.maps.GeocoderStatus.ZERO_RESULTS) {
+ deferred.resolve(null);
+ } else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
+ deferred.reject("OVER_LIMIT")
+ } else if(status === google.maps.GeocoderStatus.REQUEST_DENIED || status === google.maps.GeocoderStatus.INVALID_REQUEST) {
+ deferred.reject("FAILED");
}
- });
+ });
+ return deferred.promise;
+ }
+ };
+ return {
+ name: 'angularGeoGoogle',
+ config: function(config) {
+ // do some config? set api-key?
+
+ },
+ $get: function($log, $q) {
+ $$q = $q;
+ $$log = $log;
+ return svc;
+ }
+ }
+ });
}).call(this);
View
2 dist/providers/angulargeo-google.min.js
@@ -1 +1 @@
-(function(){"use strict";angular.module("angular-geo-providers.google",[]).provider("angularGeoGoogle",function(){var a,b;if("undefined"==typeof google||"undefined"!=typeof google&&"undefined"==typeof google.maps)throw new Error("Google Maps API V3 is required for angulargeo-google to function, please include it");var c=new google.maps.Geocoder,d={geocode:function(b){var d=a.defer();return c.geocode({address:b},function(a,b){b===google.maps.GeocoderStatus.OK?d.resolve(a):b===google.maps.GeocoderStatus.ZERO_RESULTS?d.resolve(null):b===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?d.reject("OVER_LIMIT"):(b===google.maps.GeocoderStatus.REQUEST_DENIED||b===google.maps.GeocoderStatus.INVALID_REQUEST)&&d.reject("FAILED")}),d.promise},reverseGeocode:function(){}};return{name:"angularGeoGoogle",config:function(){},$get:function(c,e){return a=e,b=c,d}}})}).call(this);
+(function(){"use strict";angular.module("angular-geo-providers.google",[]).provider("angularGeoGoogle",function(){var a,b;if("undefined"==typeof google||"undefined"!=typeof google&&"undefined"==typeof google.maps)throw new Error("Google Maps API V3 is required for angulargeo-google to function, please include it");var c=new google.maps.Geocoder,d={geocode:function(b){var d=a.defer();return c.geocode({address:b},function(a,b){b===google.maps.GeocoderStatus.OK?d.resolve(a):b===google.maps.GeocoderStatus.ZERO_RESULTS?d.resolve(null):b===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?d.reject("OVER_LIMIT"):(b===google.maps.GeocoderStatus.REQUEST_DENIED||b===google.maps.GeocoderStatus.INVALID_REQUEST)&&d.reject("FAILED")}),d.promise},reverseGeocode:function(b){var d=a.defer();return c.geocode({latLng:new google.maps.LatLng(b.latitude,b.longitude)},function(a,b){b===google.maps.GeocoderStatus.OK?d.resolve(a):b===google.maps.GeocoderStatus.ZERO_RESULTS?d.resolve(null):b===google.maps.GeocoderStatus.OVER_QUERY_LIMIT?d.reject("OVER_LIMIT"):(b===google.maps.GeocoderStatus.REQUEST_DENIED||b===google.maps.GeocoderStatus.INVALID_REQUEST)&&d.reject("FAILED")}),d.promise}};return{name:"angularGeoGoogle",config:function(){},$get:function(c,e){return a=e,b=c,d}}})}).call(this);
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "AngularGeo",
- "version": "0.2.0",
+ "version": "0.2.2",
"description": "AngularGeo\r ==========",
"main": "angulargeo.js",
"scripts": {

No commit comments for this range

Something went wrong with that request. Please try again.