Skip to content

Commit

Permalink
Merge pull request #2 from bartes/master
Browse files Browse the repository at this point in the history
make geocoding more async
  • Loading branch information
mikepugh committed Feb 1, 2015
2 parents 22d5925 + 676d254 commit 9c75791
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
16 changes: 10 additions & 6 deletions dist/providers/angulargeo-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
.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");
var $$geocoder;
var $$fetchGeocoder = function(){
if($$geocoder) return $$geocoder;
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");
}
$$geocoder = new google.maps.Geocoder();
return $$geocoder;
}
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) {
$$fetchGeocoder().geocode({'address': address}, function(results, status) {
if(status === google.maps.GeocoderStatus.OK) {
var _res = {};
_res.length = results.length;
Expand Down Expand Up @@ -85,7 +89,7 @@
},
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) {
$$fetchGeocoder().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);
Expand Down
2 changes: 1 addition & 1 deletion dist/providers/angulargeo-google.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions scripts/providers/angulargeo-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
.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");
var $$geocoder;
var $$fetchGeocoder = function(){
if($$geocoder) return $$geocoder;
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");
}
$$geocoder = new google.maps.Geocoder();
return $$geocoder;
}
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) {
$$fetchGeocoder().geocode({'address': address}, function(results, status) {
if(status === google.maps.GeocoderStatus.OK) {
var _res = {};
_res.length = results.length;
Expand Down Expand Up @@ -85,7 +89,7 @@
},
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) {
$$fetchGeocoder().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);
Expand Down

0 comments on commit 9c75791

Please sign in to comment.