You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- primary.text - A simple description of the address, usually the building & street
78
+
- secondary.text - A simple description of the location, usually the city
79
+
- geometry.centre - The coordinates of the address
80
+
- geometry.centre.type - The accuracy of the coordinates, either "address", "street" or "postcode"
81
+
- distance - How far the address is from your coordinates
82
+
- distance.geometry.centre - Your original coordinates
83
+
- populatedRecord.lines - The fully formatted postal address, line by line
84
+
- populatedRecord.label - The fully formatted postal address, in a simple label format
85
+
86
+
## Customising the response
87
+
88
+
It's possible to pass in an optional options object to customise the response. Each field is optional within the object:
89
+
90
+
- maxResults - Max number of results to return (up to 5, default: 1). Note that you are billed per result, so 4 results = 4 charges.
91
+
- distanceUnits - Unit of measurement to display how far away the address is from your coordinate ("metric", "imperial", "m", "km", "ft", "mi", default: "metric")
Swiftcomplete reverse geocoding is currently available in the following countries:
108
+
Swiftcomplete reverse geocoding is currently available in the United Kingdom. We'll be adding the following countries shortly:
32
109
33
110
- Denmark
34
111
- France
35
112
- Liechtenstein
36
113
- Luxembourg
37
114
- Norway
38
-
- United Kingdom
39
-
40
115
41
116
We regularly update and expand our data coverage - **[contact us](https://www.swiftcomplete.com/contact-us/)** if there's a country or dataset that isn't listed and we'll let you know where it is on our priority list.
Copy file name to clipboardExpand all lines: index.js
+40-8Lines changed: 40 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,34 @@ async function makeRequest(url) {
25
25
});
26
26
}
27
27
28
+
functionparseDistanceUnits(str){
29
+
letresult='';
30
+
letparsedStr=str.toLowerCase().trim();
31
+
32
+
switch(parsedStr){
33
+
case'metric':
34
+
result='metric';
35
+
break;
36
+
case'imperial':
37
+
result='imperial';
38
+
break;
39
+
case'km':
40
+
result='km';
41
+
break;
42
+
case'm':
43
+
result='m';
44
+
break;
45
+
case'mi':
46
+
result='mi';
47
+
break;
48
+
case'ft':
49
+
result='ft';
50
+
break;
51
+
}
52
+
53
+
returnresult;
54
+
}
55
+
28
56
/**
29
57
* Sets the API key to authenticate your request to the Swiftcomplete API. You can obtain an API key at https://www.swiftcomplete.com
30
58
* @param key
@@ -39,29 +67,33 @@ exports.setAPIKey = function (key) {
39
67
40
68
/**
41
69
* Returns the nearest address, street or places to a coordinate
42
-
* @param {String} coordinate A WGS84 coordinate, in the format "latitude,longitude"
70
+
* @param {string} coordinate A WGS84 coordinate, in the format "latitude,longitude"
43
71
* @param {Object} options Optional options object
44
-
* @param {Integer} options.maxResults Max number of results to return (up to 5). Note that you are billed per result, so 4 results = 4 charges.
72
+
* @param {("metric"|"imperial"|"m"|"km"|"ft"|"mi")} [options.distanceUnits="metric"] Unit of measurement to display how far away the address is from your coordinate
73
+
* @param {number} [options.maxResults=1] Max number of results to return (up to 5). Note that you are billed per result, so 4 results = 4 charges.
0 commit comments