Interface JawgPlacesMaplibreOptions

Options to configure a Places JS instance for a MapLibre or Mapbox map.

Options for JawgPlaces.MapLibre and JawgPlaces.Mapbox

interface JawgPlacesMaplibreOptions {
    accessToken?: string;
    adminArea?: AdminAreaOptions;
    boundary?: BoudaryOptions;
    clearCross?: boolean;
    container?: string | HTMLElement;
    debounceDelay?: number;
    focus?: FocusOptions;
    focusPoint?: LatLon | (() => LatLon);
    input?: string | HTMLElement;
    inputClasses?: string | string[];
    language?: string | (() => string);
    layers?:
        | string
        | string[]
        | (() => string)
        | (() => string[]);
    marker?: boolean | "all" | MapGLMarkerOptions;
    minLength?: number;
    noResultsMessage?: string | false;
    onClear?: (() => void);
    onClick?: ((feature: Feature) => void);
    onClose?: (() => void);
    onError?: ((error: any) => void);
    onFeatures?: ((features: Feature[]) => void);
    place?: MapPlaceOptions;
    placeholder?: string;
    resultContainer?: string | HTMLElement;
    reverse?: boolean | ReverseOptions;
    searchOnTyping?: boolean;
    showResultIcons?: boolean;
    size?: number;
    sources?:
        | string
        | string[]
        | (() => string[])
        | (() => string);
    transition?: MapGLTransitionOptions;
}

Hierarchy (view full)

Properties

accessToken?: string

Your personal access token, create your own on the Jawg Lab. This is filled automatically when you get the library with our CDN or @jawg/js-loader.

adminArea?: AdminAreaOptions

Set of options to display the selected administrative area on the map when it's available.

const adminArea = {
show: true,
fillColor: 'rgba(0,75,120, 0.1)',
outlineColor: 'rgba(0,75,120, 1)',
}
boundary?: BoudaryOptions

Set of options to restrict your forward geocoding to specific regions. It will filter out all locations outside of the configured boundaries.

const boundary = {
countries: 'fra',
circle: { lat: 46.842269, lon: 2.39985, radius: 500 },
rectangle: {
min: { lat: 43.032582, lon: 5.097656 },
max: { lat: 49.006466, lon: 26.762695 },
},
gids: ['openstreetmap:island:relation/966358']
}
clearCross?: boolean

Add a clear cross in the right side of the input.

container?: string | HTMLElement

The custom <div> that will contain the input and geocoding results when Places JS is used as MapLibre Control. By default this is generated by Jawg Places JS. With some frameworks/UI libs such as React, you can't use the ref here.

debounceDelay?: number

Set the number of milliseconds to wait before a search validation. If you press Enter the search will be immediately validated. This option work only when searchOnTyping=true.

with a basic plan you may set this option to 1000 to avoid your restrictions.

350
focus?: FocusOptions

Set of options to prioritize your forward geocoding to specific regions. All locations in these regions will have a better ranking.

const focus = {
countries: 'fra',
point: { lat: 46.842269, lon: 2.39985 },
gids: ['openstreetmap:island:relation/966358']
}
focusPoint?: LatLon | (() => LatLon)

Sort results in part by their proximity to the given coordinate. Coordinates can be static or dynamic with the function.

Point can be static or dynamic through a function. The radius is 50km and cannot be changed.

Replaced by FocusOptions.point

input?: string | HTMLElement

The <input> to transform into a geocoding search bar. This can be either an id (e.g #my-input), class selector (e.g .my-input) or the HTMLElement. With some frameworks/UI libs such as React, you can't use the ref here.

inputClasses?: string | string[]

Class to add to the input when it's generated by the library.

language?: string | (() => string)

Return results in a specific language using BCP47 standard (e.g 'en', 'fr', 'de', ...). By default, we use HTTP Header set by the browser and English when not present.

Language can be static or dynamic through a function.

layers?:
    | string
    | string[]
    | (() => string)
    | (() => string[])

Restrict your search (forward and reverse) to specific layers. You can get only addresses or administrative areas for example.

Layers can be static or dynamic through a function.

marker?: boolean | "all" | MapGLMarkerOptions

Option for MapLibre and Mapbox markers.

minLength?: number

Set the minimum number of characters to trigger a geocoding request. If you press Enter the search will be validated even if the length is not reached. This option work only when searchOnTyping=true.

0.
noResultsMessage?: string | false

Set a custom message when no results are found. This can be disabled.

onClear?: (() => void)

Callback triggered when the input is empty.

onClick?: ((feature: Feature) => void)

Callback triggered when the user click on a result.

Type declaration

    • (feature): void
    • Parameters

      • feature: Feature

        The feature selected by the user

      Returns void

onClose?: (() => void)

Callback triggered when the result list is closed/cleared.

onError?: ((error: any) => void)

Callback triggered when Jawg Places API returns an error.

onFeatures?: ((features: Feature[]) => void)

Callback triggered when Jawg Places API returns without error.

Type declaration

    • (features): void
    • Parameters

      • features: Feature[]

        The list of features returned by Jawg Places API

      Returns void

Option to activate Place Details detection within the input. You can paste one or many GIDs in the input. The separation can be either , (comma) or (space).

const place = {
enabled: true,
geometries: 'source',
fillColor: 'rgba(105,87,117, 0.1)',
outlineColor: 'rgba(105,87,117, 1)',
}
placeholder?: string

Placeholder text to add when the input in generated by the library.

resultContainer?: string | HTMLElement

The custom <div> that will contain the geocoding results. By default the container is created by Jawg Places JS. With some frameworks/UI libs such as React, you can't use the ref here.

reverse?: boolean | ReverseOptions

Option to activate Reverse Geocoding detection within the input. You can paste coordinates in the form {lat}/{lon} in the input. The separation can be either / (slash), , (comma) or (space).

const reverse = {
enabled: true,
radius: 5,
}
false
searchOnTyping?: boolean

Set this to true to activate search on typing, this will also use autocomplete search. Default value is false, you will need to press Enter to validate your search.

showResultIcons?: boolean

Show icon at the left each results.

size?: number

Set the maximum number of results for forward and reverse geocoding.

10
sources?:
    | string
    | string[]
    | (() => string[])
    | (() => string)

Restrict your search (forward and reverse) to specific data sources. You can get only OSM or WOF data for example. This is not recommanded.

Sources can be static or dynamic through a function.

Set of options to configure the transition when the user click on a result on MapLibre or Mapbox.

const transition = {
type: 'hybrid',
flyCurve: 1.42,
flySpeed: 1.2,
}