Optional
bbox?: number[]Optional
clearAndBlurOnEsc?: booleanIf true
, the geocoder control will clear it's contents and blur when user presses the escape key.
Optional
clearOnBlur?: booleanIf 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
debounceSearch?: numberSets 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
enableEventLogging?: booleanAllow Maplibre to collect anonymous usage statistics from the plugin.
Optional
externalGeocoder?: (A 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) => booleanA 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
flyTo?: boolean | FlyToOptionsOptional
getItemValue?: (item: CarmenGeojsonFeature) => stringA 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
localGeocoder?: (query: string) => CarmenGeojsonFeature[]A 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
localGeocoderOnly?: booleanIf 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
minLength?: numberMinimum 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
popupRender?: (item: CarmenGeojsonFeature) => stringA function that specifies how the results should be rendered in the popup menu. Any HTML in the returned string will be rendered.
Optional
proximity?: { latitude: number; longitude: number }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
proximityMinZoom?: numberIf setting promiximity, this is the minimum zoom level at which to start taking it into account.
Optional
render?: (item: CarmenGeojsonFeature) => stringA function that specifies how the results should be rendered in the dropdown menu. Any HTML in the returned string will be rendered.
Optional
reverseGeocode?: booleanIf 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
reverseMode?: "distance" | "score"Set the factors that are used to sort nearby results.
Optional
showResultMarkers?: boolean | MarkerOptionsIf 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
showResultsWhileTyping?: booleanIf 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
trackProximity?: booleanIf 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.