Permalink
Browse files

Update dist

  • Loading branch information...
mikepugh committed Feb 3, 2014
1 parent ae2e51e commit 4293e844b1b8624062bf4e84b2b16a23e7883e78
Showing with 81 additions and 48 deletions.
  1. +1 −3 Gruntfile.js
  2. +24 −2 dist/angulargeo.js
  3. +1 −1 dist/angulargeo.min.js
  4. +54 −41 dist/providers/angulargeo-google.js
  5. +1 −1 dist/providers/angulargeo-google.min.js
View
@@ -201,13 +201,11 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
- 'ngmin',
'copy:dist',
'uglify'
]);
grunt.registerTask('default', [
- 'test',
- 'serve'
+ 'build'
]);
};
View
@@ -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

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

Oops, something went wrong.
@@ -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);

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

Oops, something went wrong.

0 comments on commit 4293e84

Please sign in to comment.