-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
50 lines (38 loc) · 1.11 KB
/
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
41
42
43
44
45
46
47
48
49
50
'use strict';
const express = require('express');
const GeoCacher = require('./geocacher');
let app = express();
const geoCacher = GeoCacher.initialize({
'mode' : 'mongodb',
'dbURL' : 'mongodb://localhost:27017/logixmapdata',
'maxDistance': 25, //Required
'resultLimit':1 // Optional for Mongo
});
geoCacher.on('ready', (status) => {
geoCacher.reverseGeoCode(121.001651, 14.632906, (error, result) => {
if (error) {
console.log('reverse', error.message)
} else {
console.log('reverse', result)
}
});
let reverseGeo = { provider: 'Google',
full_address: '645 Banawe St, Santa Mesa Heights, Quezon City, 1114 Metro Manila, Philippines',
street_number: '645',
street: 'Banawe Street',
city: 'Quezon City',
municipality2: 'Metro Manila',
municipality: 'Metro Manila',
country: 'Philippines',
countryCode: 'PH',
postal_code: '1114',
coords: [121.001651,14.632906]}
geoCacher.saveGeoCache(reverseGeo, result => {
console.log('saveGeoCache', result)
});
})
geoCacher.on('error', (err) => {
console.log(err);
});
geoCacher.start()
let server = app.listen(3030);