You are viewing an older version of MapQuest.js. Check out the latest version.
A control that adds interactive geocoding functionality to the map. Geocoded locations will have markers set to their locations. If enabled, the Search Ahead API will provide predictive results based on the provided input.
L.mapquest.key = 'KEY';
var map = L.mapquest.map('map', {
center: [39.7392,-104.9903],
layers: L.mapquest.tileLayer('map'),
zoom: 12
});
map.addControl(L.mapquest.control());
map.addControl(L.mapquest.geocodingControl({
position: 'topleft'
}));
An object containing any of the following key value options: position, keepOpen, searchAhead, compactResults, closeResultsOnClick, geocodingOptions, and searchAheadOptions.
The position of the control (one of the map corners).
Possible values are 'topleft', 'topright', 'bottomleft' or 'bottomright'.
Determines if input field of the control should remain open after a geocode.
Determines if the Search Ahead functionality should be enabled on the control.
If L.mapquest.open
is set to true
, this feature will automatically be disabled.
Options to be passed into the Search Ahead API if it is enabled.
Any Request Parameters of the Search Ahead API are valid options.
If the location
parameter is not set in this object, Search Ahead results will be based on the current map center.
Options to be passed into the Geocoding API.
Any Request Parameters of the Geocoding API are valid options.
Determines if a compact version of Search Ahead results should be used.
Determines if Search Ahead results should automatically close when a result is selected.
{
position: 'topright',
keepOpen: false,
searchAhead: true,
compactResults: true,
closeResultsOnClick: true,
searchAheadOptions: {
limit: 6
}
}
An L.Control object that can be added to a map with the addControl() function.