This class will help you add or use search bar for geocoding with a Mapbox GL JS map.

const jawgPlaces = new JawgPlaces.Mapbox({
accessToken: 'Access-Token',
})
map.addControl(jawgPlaces)

Hierarchy (View Summary)

Constructors

Methods

  • When Jawg Places is not used as a control within your map, you will need to call this function.

    Parameters

    Returns this

    itself

  • Destroy all created DOM elements and listeners. This could be useful when you recreate a JawgPlace instance for the same input.

    Returns void

  • Search a random text, lat/lon or GID using Jawg Places.

    All features are points with properties, more details on our documentation.

    See JawgPlacesOptions.reverse for lat/lon search and JawgPlacesOptions.place for GID search.

    Parameters

    • text: string

      The text to search using Jawg Places

    Returns Promise<FeatureCollection>

    A promise with the feature collection received from Jawg Places

  • Open the result list with the error message. This will trigger JawgPlacesOptions.onError.

    Parameters

    • error: any

      The error to show, can be a string or an object.

    Returns void

  • Open the result list with elements from the FeatureCollection. We use the properties.label field of each features. This will trigger JawgPlacesOptions.onFeatures callback. Use it if you want to display specific results or add new elements.

    Parameters

    Returns void

  • Submit the search using the value of the <input>. This will trigger JawgPlacesOptions.onFeatures.

    Returns void