-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
40 lines (33 loc) · 1019 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var _ = require('underscore');
var Searcher = require('./communicator/request');
/**
* Wrapper - call Open Street Map (OSM) geocoder and parse result
*/
function SearchWrapper() {}
SearchWrapper.prototype.extendCallback = function (callback) {
var Parser = require('./parser');
return function (error, data) {
error = Parser.parseError(error);
data = Parser.parseData(data);
if (_.isFunction(callback)) {
callback(error, data);
}
}
}
/**
* @access public
*/
SearchWrapper.prototype.geocode = function (address, callback, options) {
var extendedCallback = this.extendCallback(callback);
var searcher = new Searcher();
searcher.geocode(address, extendedCallback, options);
}
/**
* @access public
*/
SearchWrapper.prototype.reverseGeocode = function (lat, lng, callback, options) {
var extendedCallback = this.extendCallback(callback);
var searcher = new Searcher();
searcher.reverseGeocode(lat, lng, extendedCallback, options);
}
module.exports = new SearchWrapper();