You are viewing an older version of MapQuest.js. Check out the latest version.
A class that acts as a simple interface to the MapQuest Geocoding API. Forward, Reverse, and Batch Geocoding are supported through the class.
L.mapquest.key = 'KEY';
var geocoder = L.mapquest.geocoding({
thumbMaps: false,
maxResults: 3
});
An object containing options from the Geocoding API.
A geocoding object configured with the provided options.
Performs a forward geocode on the provided locations.
L.mapquest.key = 'KEY';
var geocoder = L.mapquest.geocoding();
geocoder.geocode(['Denver, CO', 'Boulder, CO'], geocodingCallback);
function geocodingCallback(error, result) {
console.log(result);
}
The locations parameter may be either a single line address as a string, an advanced location object, an array of multiple single line address strings, or an array of advanced location objects.
If an array of locations is provided, the Batch Geocode API will be used.
{ city: 'Denver', state: 'CO' }
[{ city: 'Boulder', state: 'CO'}, { city: 'Denver', state: 'CO' }]
'Denver, CO'
['Denver, CO', 'Boulder, CO']
Optional callback function. If provided, the results of the API call will be passed into the function in the error-first callback style. If not provided, geocoded locations will be displayed on the map with markers set to their locations.
If a callback is provided, the Geocoding API response will be returned.
Performs a reverse geocode on the provided lat/lng.
L.mapquest.key = 'KEY';
var geocoder = L.mapquest.geocoding();
geocoder.reverse([37.78008,-122.420168], geocodingCallback);
function geocodingCallback(error, result) {
console.log(result);
}
Either an advanced location object, an object with lat
and lng
keys, or a lat,lng array.
{ latLng: {lat: '40.7128', lng: '-74.0059'} }
L.latLng([-81.470448, 30.333472])
[-81.470448, 30.333472]
Optional callback function. If provided, the results of the API call will be passed into the function in the error-first callback style. If not provided, geocoded locations will be displayed on the map with markers set to their locations.
If a callback is provided, the Geocoding API response will be returned.