OptionalbboxOptionalclearIf true, the geocoder control will clear it's contents and blur when user presses the escape key.
OptionalclearIf true, the geocoder control will clear its value when the input blurs.
OptionalcollapsedIf true, the geocoder control will collapse until hovered or in focus.
OptionalcountriesA comma separated list of country codes to limit results to specified country or countries.
OptionaldebounceSets 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.
OptionalenableAllow Maplibre to collect anonymous usage statistics from the plugin.
OptionalexternalA 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.
OptionalfilterA 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.
OptionalflyOptionalgetA 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);
OptionallanguageSpecify 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.
OptionallimitMaximum number of results to show.
OptionallocalA function accepting the query string which performs local geocoding to supplement results from the Maplibre Geocoding API. Expected to return an Array of CarmenGeojsonFeature.
OptionallocalIf 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.
OptionalmaplibreglA maplibre-gl instance to use when creating Markers. Required if options.marker is true.
OptionalmarkerIf 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.
OptionalminMinimum number of characters to enter before results are shown.
OptionalplaceholderOverride the default placeholder attribute value.
OptionalpopupIf 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.
OptionalpopupA function that specifies how the results should be rendered in the popup menu. Any HTML in the returned string will be rendered.
Optionalproximitya 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.
OptionalproximityIf setting promiximity, this is the minimum zoom level at which to start taking it into account.
OptionalrenderA function that specifies how the results should be rendered in the dropdown menu. Any HTML in the returned string will be rendered.
OptionalreverseIf 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.
OptionalreverseSet the factors that are used to sort nearby results.
OptionalshowIf 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.
OptionalshowIf 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.
OptionaltrackIf true, the geocoder proximity will automatically update based on the map view.
OptionaltypesA 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.
OptionalzoomOn 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.