mapbox / mapbox-gl-geocoder

Geocoder control for mapbox-gl-js using Mapbox Geocoding API
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-geocoder/
ISC License
362 stars 181 forks source link

[Question] Is it possible to have custom html for the input field? #463

Closed JeremieBergeron closed 1 year ago

JeremieBergeron commented 2 years ago

Is it possible to have custom html for the input field? image

Warning: I am not talking about the dropdown!

I would like to only display the place.

VladislavMedved commented 1 year ago

hey @JeremieBergeron

To control what exactly to show in input field after selection you can use getItemValue function. It accepts the whole geojson object and you can choose what properties to use

const geocoder = new MapboxGeocoder({
  accessToken: mapboxgl.accessToken,
  mapboxgl: mapboxgl,
  getItemValue: (item) => item.place_name
});
JeremieBergeron commented 1 year ago

Thanks !