A geocoder component using Mapbox Geocoding API
Parameters
optionsObjectoptions.zoomNumber On geocoded result what zoom level should the map animate to when abboxisn't found in the response. If abboxis found the map will fit to thebbox. (optional, default16)options.flyToBoolean If false, animating the map to a selected result is disabled. (optional, defaulttrue)options.placeholderString Override the default placeholder attribute value. (optional, default"Search for Place or Address")options.minLengthNumber Minimum number of characters to enter before results are shown. (optional, default2)options.limitNumber Maximum number of results to show. (optional, default5)
geocodeRequestFunction 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
Subscribe to events that happen within the plugin.
Parameters
typeString name of event. Available events and the data passed into their respective event objects are:- clearEmitted 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
- loading
fnFunction function that's called when the event is emitted.
Returns MapboxGenericGeocoder this;
Remove an event
Parameters
Returns MapboxGenericGeocoder this