Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 3.26 KB

API.md

File metadata and controls

56 lines (37 loc) · 3.26 KB

Table of Contents

MapboxGenericGeocoder

A geocoder component using Mapbox Geocoding API

Parameters

  • options Object
    • options.zoom 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. (optional, default 16)
    • options.flyTo Boolean If false, animating the map to a selected result is disabled. (optional, default true)
    • options.placeholder String Override the default placeholder attribute value. (optional, default "Search for Place or Address")
    • options.minLength Number Minimum number of characters to enter before results are shown. (optional, default 2)
    • options.limit Number Maximum number of results to show. (optional, default 5)
  • geocodeRequest Function A function that take a object containing the query text, current map bounds, and options. It returns a promise with an array of result. A result should look like something like this: { "name": "Denver", "lat": 39.742043, "lon": -104.991531, "bbox": ["-105.1098845", "39.6143154","-104.5996889","39.9142087"]}

Examples

var geocoder = new MapboxGenericGeocoder();
map.addControl(geocoder);

Returns MapboxGenericGeocoder this

on

Subscribe to events that happen within the plugin.

Parameters

  • type String name of event. Available events and the data passed into their respective event objects are:- clear Emitted when the input is cleared
    • loading { query } Emitted when the geocoder is looking up a query
    • results { results } Fired when the geocoder returns a response
    • result { result } Fired when input is set
    • error `{ error } Error as string
  • fn Function function that's called when the event is emitted.

Returns MapboxGenericGeocoder this;

off

Remove an event

Parameters

  • type String Event name.
  • fn Function Function that should unsubscribe to the event emitted.

Returns MapboxGenericGeocoder this