-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bounds): Extracted the nominatim functionality as a service, to …
…be able to use it from center and markers
- Loading branch information
1 parent
4898629
commit 11e9e31
Showing
2 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
angular.module("leaflet-directive").factory('nominatimService', function ($q, $http, leafletHelpers, leafletMapDefaults) { | ||
var isDefined = leafletHelpers.isDefined; | ||
|
||
return { | ||
query: function(address, mapId) { | ||
var defaults = leafletMapDefaults.getDefaults(mapId); | ||
var url = defaults.nominatim.server; | ||
var df = $q.defer(); | ||
|
||
$http.get(url, { params: { format: 'json', limit: 1, q: address } }).success(function(data) { | ||
if (data.length > 0 && isDefined(data[0].boundingbox)) { | ||
df.resolve(data[0]); | ||
} else { | ||
df.reject('[Nominatim] Invalid address'); | ||
} | ||
}); | ||
|
||
return df.promise; | ||
} | ||
}; | ||
}); |