const geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl,
});
if (locationFromUrl && idFromUrl) {
// Reverse geocode to get the place name
reverseGeocode(locationFromUrl[0], locationFromUrl[1], placeIdFromUrl).then(placeName => {
if (placeName) {
geocoder.setInput(placeName, false);
}
});
}
The code:
const geocoder = new MapboxGeocoder({ accessToken: mapboxgl.accessToken, mapboxgl: mapboxgl, });
if (locationFromUrl && idFromUrl) {
// Reverse geocode to get the place name reverseGeocode(locationFromUrl[0], locationFromUrl[1], placeIdFromUrl).then(placeName => { if (placeName) { geocoder.setInput(placeName, false); } }); }
The result: