MaplibreGeocoderOptions: {
    bbox?: number[];
    clearAndBlurOnEsc?: boolean;
    clearOnBlur?: boolean;
    collapsed?: boolean;
    countries?: string;
    debounceSearch?: number;
    enableEventLogging?: boolean;
    externalGeocoder?: ((query: string, features: CarmenGeojsonFeature[], confic: MaplibreGeocoderApiConfig) => Promise<CarmenGeojsonFeature[]>);
    filter?: ((item: CarmenGeojsonFeature) => boolean);
    flyTo?: boolean | FlyToOptions;
    getItemValue?: ((item: CarmenGeojsonFeature) => string);
    language?: string;
    limit?: number;
    localGeocoder?: ((query: string) => CarmenGeojsonFeature[]);
    localGeocoderOnly?: boolean;
    maplibregl?: typeof MaplibreGl;
    marker?: boolean | Marker;
    minLength?: number;
    placeholder?: string;
    popup?: boolean | Popup;
    popupRender?: ((item: CarmenGeojsonFeature) => string);
    proximity?: {
        latitude: number;
        longitude: number;
    };
    render?: ((item: CarmenGeojsonFeature) => string);
    reverseGeocode?: boolean;
    reverseMode?: "distance" | "score";
    showResultMarkers?: boolean | MarkerOptions;
    showResultsWhileTyping?: boolean;
    trackProximity?: boolean;
    types?: string;
    zoom?: number;
}

Type declaration

  • Optionalbbox?: number[]

    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.

  • OptionalclearAndBlurOnEsc?: boolean

    If true, the geocoder control will clear it's contents and blur when user presses the escape key.

    false
    
  • OptionalclearOnBlur?: boolean

    If true, the geocoder control will clear its value when the input blurs.

    false
    
  • Optionalcollapsed?: boolean

    If true, the geocoder control will collapse until hovered or in focus.

    false
    
  • Optionalcountries?: string

    A comma separated list of country codes to limit results to specified country or countries.

  • OptionaldebounceSearch?: number

    Sets 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.

    200
    
  • OptionalenableEventLogging?: boolean

    Allow Maplibre to collect anonymous usage statistics from the plugin.

    true
    
  • OptionalexternalGeocoder?: ((query: string, features: CarmenGeojsonFeature[], confic: MaplibreGeocoderApiConfig) => Promise<CarmenGeojsonFeature[]>)

    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.

  • Optionalfilter?: ((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.

  • OptionalflyTo?: boolean | FlyToOptions

    If false, animating the map to a selected result is disabled. If true, animating the map will use the default animation parameters. If an object, it will be passed as options to the map flyTo or fitBounds method providing control over the animation of the transition.

    true
    
  • OptionalgetItemValue?: ((item: CarmenGeojsonFeature) => string)

    A 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);
  • Optionallanguage?: string

    Specify 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.

  • Optionallimit?: number

    Maximum number of results to show.

    5
    
  • OptionallocalGeocoder?: ((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.

  • OptionallocalGeocoderOnly?: boolean

    If 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.

    false
    
  • Optionalmaplibregl?: typeof MaplibreGl

    A maplibre-gl instance to use when creating Markers. Required if options.marker is true.

    false
    
  • Optionalmarker?: boolean | Marker

    If 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.

    true
    
  • OptionalminLength?: number

    Minimum number of characters to enter before results are shown.

    2
    
  • Optionalplaceholder?: string

    Override the default placeholder attribute value.

    "Search"
    
  • Optionalpopup?: boolean | Popup

    If 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.

    false
    
  • OptionalpopupRender?: ((item: CarmenGeojsonFeature) => string)

    A function that specifies how the results should be rendered in the popup menu. Any HTML in the returned string will be rendered.

  • Optionalproximity?: {
        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.

    • latitude: number
    • longitude: number
  • Optionalrender?: ((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.

  • OptionalreverseGeocode?: boolean

    If 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.

    false
    
  • OptionalreverseMode?: "distance" | "score"

    Set the factors that are used to sort nearby results.

  • OptionalshowResultMarkers?: boolean | MarkerOptions

    If 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.

    true
    
  • OptionalshowResultsWhileTyping?: boolean

    If 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.

    false
    
  • OptionaltrackProximity?: boolean

    If true, the geocoder proximity will automatically update based on the map view.

    true
    
  • Optionaltypes?: string

    A 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.

  • Optionalzoom?: number

    On 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.

    16