Skip to content

Commit 9199750

Browse files
support v6 api in MapboxGeocoder class
pre-validate reverse coordinates to avoid v6 4xx response fix limit=1 on reverse geocodes when single type set enable multiple reverse results when no types or limit specified fix promise resolution revert package-lock file fix potential problem with address strings for v5 and v6
1 parent 056c09c commit 9199750

File tree

7 files changed

+254
-46
lines changed

7 files changed

+254
-46
lines changed

debug/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ var geocoder = new MapboxGeocoder({
8585
.then(response => response.json())
8686
}
8787
},
88-
mapboxgl: mapboxgl
88+
mapboxgl: mapboxgl,
89+
reverseGeocode: true,
90+
version: 'v6',
8991
});
9092

9193
map.addControl(geocoder)

debug/mock-api.json

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
11
[
2-
{"id":"place.7673410831246050","type":"Feature","place_type":["place"],"relevance":1,"properties":{"wikidata":"Q61"},"text_en-US":"Washington","language_en-US":"en","place_name_en-US":"Washington, District of Columbia, United States of America","text":"Washington","language":"en","place_name":"SERVER: Washington, District of Columbia, United States of America","matching_place_name":"Washington, DC, United States of America","bbox":[-77.1197609567342,38.79155738,-76.909391,38.99555093],"center":[-77.0366,38.895],"geometry":{"type":"Point","coordinates":[-77.0366,38.895]},"context":[{"id":"region.14064402149979320","short_code":"US-DC","wikidata":"Q3551781","text_en-US":"District of Columbia","language_en-US":"en","text":"District of Columbia","language":"en"},{"id":"country.19678805456372290","wikidata":"Q30","short_code":"us","text_en-US":"United States of America","language_en-US":"en","text":"United States of America","language":"en"}]}
3-
]
2+
{
3+
"type": "Feature",
4+
"id": "address.7840146147075390",
5+
"geometry": {
6+
"type": "Point",
7+
"coordinates": [22.476772, -33.991656]
8+
},
9+
"properties": {
10+
"mapbox_id": "address.7840146147075390",
11+
"feature_type": "address",
12+
"name": "12 Main Street",
13+
"coordinates": {
14+
"longitude": 22.476772,
15+
"latitude": -33.991656,
16+
"accuracy": "proximate"
17+
},
18+
"place_formatted": "George, Western Cape 6529, South Africa",
19+
"match_code": {
20+
"address_number": "matched",
21+
"street": "unmatched",
22+
"postcode": "unmatched",
23+
"place": "unmatched",
24+
"region": "unmatched",
25+
"locality": "not_applicable",
26+
"country": "inferred",
27+
"confidence": "low"
28+
},
29+
"context": {
30+
"address": {
31+
"id": "address.7840146147075390",
32+
"street": "Main Street",
33+
"address_number": "12",
34+
"name": "12 Main Street"
35+
},
36+
"neighborhood": {
37+
"id": "neighborhood.1846526",
38+
"name": "Ballotsview"
39+
},
40+
"postcode": {
41+
"id": "postcode.24039166",
42+
"name": "6529"
43+
},
44+
"place": {
45+
"id": "place.24643838",
46+
"name": "George",
47+
"wikidata_id": "Q370456"
48+
},
49+
"region": {
50+
"id": "region.9470",
51+
"name": "Western Cape",
52+
"wikidata_id": "Q127167",
53+
"region_code": "WC",
54+
"region_code_full": "ZA-WC"
55+
},
56+
"country": {
57+
"id": "country.8958",
58+
"name": "South Africa",
59+
"wikidata_id": "Q258",
60+
"country_code": "ZA",
61+
"country_code_alpha_3": "ZAF"
62+
}
63+
}
64+
}
65+
}
66+
]

lib/events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ MapboxEventManager.prototype = {
179179
routing: geocoder.options.routing,
180180
worldview: geocoder.options.worldview,
181181
mapZoom: zoom,
182-
keyboardLocale: this.locale
182+
keyboardLocale: this.locale,
183+
apiVersion: geocoder.options.version
183184
}
184185

185186
// get the text in the search bar

0 commit comments

Comments
 (0)