Optional
bbox?: number[]Optional
clearIf true
, the geocoder control will clear it's contents and blur when user presses the escape key.
Optional
clearIf true
, the geocoder control will clear its value when the input blurs.
Optional
collapsed?: booleanIf true
, the geocoder control will collapse until hovered or in focus.
Optional
countries?: stringA comma separated list of country codes to limit results to specified country or countries.
Optional
debounceSets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box. This parameter may be useful for reducing the total number of API calls made for a single query.
Optional
enableAllow Maplibre to collect anonymous usage statistics from the plugin.
Optional
externalA function accepting the query string, current features list, and geocoder options which performs geocoding to supplement results from the Maplibre Geocoding API. Expected to return a Promise which resolves to an Array of CarmenGeojsonFeature.
Optional
filter?: ((item: CarmenGeojsonFeature) => boolean)A function which accepts a CarmenGeojsonFeature to filter out results from the Geocoding API response before they are included in the suggestions list. Return true
to keep the item, false
otherwise.
Optional
flyOptional
getA function that specifies how the selected result should be rendered in the search bar. HTML tags in the output string will not be rendered. Defaults to (item) => item.place_name
.
const GeoApi = {
forwardGeocode: (config) => { return { features: [] } },
reverseGeocode: (config) => { return { features: [] } }
getSuggestions: (config) => { return { suggestions: {text: string, placeId?: string}[] }}
searchByPlaceId: (config) => { return { place: {type: string, geometry: {type: string, coordinates: [number]} place_name: string, text: string, center: [number] }[] }}
}
const geocoder = new MaplibreGeocoder(GeoApi, {});
map.addControl(geocoder);
Optional
language?: stringSpecify the language to use for response text and query result weighting. Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script. More than one value can also be specified, separated by commas. Defaults to the browser's language settings.
Optional
limit?: numberMaximum number of results to show.
Optional
localA function accepting the query string which performs local geocoding to supplement results from the Maplibre Geocoding API. Expected to return an Array of CarmenGeojsonFeature.
Optional
localIf true
, indicates that the localGeocoder
results should be the only ones returned to the user. If false
, indicates that the localGeocoder
results should be combined with those from the Maplibre API with the localGeocoder
results ranked higher.
Optional
maplibregl?: typeof MaplibreGlA maplibre-gl instance to use when creating Markers. Required if options.marker
is true
.
Optional
marker?: boolean | MarkerIf true
, a Marker will be added to the map at the location of the user-selected result using a default set of Marker options. If the value is an object, the marker will be constructed using these options. If false
, no marker will be added to the map. Requires that options.maplibregl
also be set.
Optional
minMinimum number of characters to enter before results are shown.
Optional
placeholder?: stringOverride the default placeholder attribute value.
Optional
popup?: boolean | PopupIf true
, a Popup will be added to the map when clicking on a marker using a default set of popup options. If the value is an object, the popup will be constructed using these options. If false
, no popup will be added to the map. Requires that options.maplibregl
also be set.
Optional
popupA function that specifies how the results should be rendered in the popup menu. Any HTML in the returned string will be rendered.
Optional
proximity?: { a proximity argument: this is a geographical point given as an object with latitude
and longitude
properties.
Search results closer to this point will be given higher priority.
Optional
render?: ((item: CarmenGeojsonFeature) => string)A function that specifies how the results should be rendered in the dropdown menu. Any HTML in the returned string will be rendered.
Optional
reverseIf true
, enable reverse geocoding mode. In reverse geocoding, search input is expected to be coordinates in the form lat, lon
, with suggestions being the reverse geocodes.
Optional
reverseSet the factors that are used to sort nearby results.
Optional
showIf true
, Markers will be added to the map at the location the top results for the query. If the value is an object, the marker will be constructed using these options. If false
, no marker will be added to the map. Requires that options.maplibregl
also be set.
Optional
showIf false
, indicates that search will only occur on enter key press. If true
, indicates that the Geocoder will search on the input box being updated above the minLength option.
Optional
trackIf true
, the geocoder proximity will automatically update based on the map view.
Optional
types?: stringA comma seperated list of types that filter results to match those specified. See https://docs.mapbox.com/api/search/#data-types for available types. If reverseGeocode is enabled, you should specify one type. If you configure more than one type, the first type will be used.
Optional
zoom?: numberOn geocoded result what zoom level should the map animate to when a bbox
isn't found in the response. If a bbox
is found the map will fit to the bbox
.
A bounding box argument: this is a bounding box given as an array in the format
[minX, minY, maxX, maxY]
. Search results will be limited to the bounding box.