Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version flag for MapboxGeocoder #485

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 128 additions & 109 deletions API.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## HEAD

## 5.1.0-beta.0

### Features / Improvements 🚀

- Added version="v5"|"v6" flag to the options of the MapboxGeocoder class which makes it possible to use v6 endpoint instead of v5 by default for geocoding. [#485](https://github.com/mapbox/mapbox-gl-geocoder/pull/485). For more details please refer to [v6 API documentation](https://docs.mapbox.com/api/search/geocoding-v6/).

## 5.0.1

### Bug fixes 🐛
Expand Down
4 changes: 3 additions & 1 deletion debug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ var geocoder = new MapboxGeocoder({
.then(response => response.json())
}
},
mapboxgl: mapboxgl
mapboxgl: mapboxgl,
reverseGeocode: true,
version: 'v6',
});

map.addControl(geocoder)
Expand Down
67 changes: 65 additions & 2 deletions debug/mock-api.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
[
{"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"}]}
]
{
"type": "Feature",
"id": "address.7840146147075390",
"geometry": {
"type": "Point",
"coordinates": [22.476772, -33.991656]
},
"properties": {
"mapbox_id": "address.7840146147075390",
"feature_type": "address",
"name": "12 Main Street",
"coordinates": {
"longitude": 22.476772,
"latitude": -33.991656,
"accuracy": "proximate"
},
"place_formatted": "George, Western Cape 6529, South Africa",
"match_code": {
"address_number": "matched",
"street": "unmatched",
"postcode": "unmatched",
"place": "unmatched",
"region": "unmatched",
"locality": "not_applicable",
"country": "inferred",
"confidence": "low"
},
"context": {
"address": {
"id": "address.7840146147075390",
"street": "Main Street",
"address_number": "12",
"name": "12 Main Street"
},
"neighborhood": {
"id": "neighborhood.1846526",
"name": "Ballotsview"
},
"postcode": {
"id": "postcode.24039166",
"name": "6529"
},
"place": {
"id": "place.24643838",
"name": "George",
"wikidata_id": "Q370456"
},
"region": {
"id": "region.9470",
"name": "Western Cape",
"wikidata_id": "Q127167",
"region_code": "WC",
"region_code_full": "ZA-WC"
},
"country": {
"id": "country.8958",
"name": "South Africa",
"wikidata_id": "Q258",
"country_code": "ZA",
"country_code_alpha_3": "ZAF"
}
}
}
}
]
3 changes: 2 additions & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ MapboxEventManager.prototype = {
routing: geocoder.options.routing,
worldview: geocoder.options.worldview,
mapZoom: zoom,
keyboardLocale: this.locale
keyboardLocale: this.locale,
apiVersion: geocoder.options.version
}

// get the text in the search bar
Expand Down
Loading