-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
node.js
47 lines (43 loc) · 1.19 KB
/
node.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
/* eslint-disable no-console */
const opencage = require('..');
opencage
.geocode({ q: 'rue de la république lyon', limit: 3 })
.then((data) => {
console.log('geocode ---------------------------------');
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log('Error caught:', error.message);
});
opencage
.geocode({ q: '45.188529 5.724524' })
.then((data) => {
console.log('reverse geocode -------------------------');
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log('Error caught:', error.message);
});
opencage
.geocode({ q: '45.188529 5.724524', language: 'fr' })
.then((data) => {
console.log('reverse geocode fr -------------------------');
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log('Error caught:', error.message);
});
opencage
.geocode({
q: 'rue de la république lyon',
proximity: '51.952659, 7.632473',
no_annotations: 1,
limit: 3,
})
.then((data) => {
console.log('geocode with proximity ---------------------------------');
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log('Error caught:', error.message);
});