The geocode object performing geocoding, batch geocoding and reverse geocoding on the map.
Converts a string location into a pair of geocodes. Optionally adds a marker on the map.
var map = new mqgl.Map('map', 'KEY');
map.load( () => {
map.geocode('Denver, CO', {addMarker: true})
.then( () => map.fitBounds() );
});
var map = new mqgl.Map('map', 'KEY');
map.load( () => {
map.geocode('1555 Blake St, Denver, CO', {addMarker: true})
.then( () => {
return map.geocode('Boulder, CO')
})
.then( point => {
map.icons.marker.add(point, 'marker-sm-blue.png');
})
.then( () => map.fitBounds() );
});
A single location to be geocoded. Advanced Location Objects are also supported.
'Washington, DC'
{
location: {
street: '1555 Blake St',
city: 'Denver',
county: 'Denver',
state: 'CO'
}
}
In addition to the options from the Geocoding API, the "addMarker" option (boolean, default is false) determines if a marker should be added after the location is geocoded.
A Promise, consisting of a single geocode object: {lng, lat}
Converts an array of string locations into pairs of geocodes. Optionally adds a marker on the map.
var map = new mqgl.Map('map', 'KEY');
map.load( () => {
map.batchGeocode(['Denver, CO', 'Boulder, CO', 'Fort Collins, CO'], {addMarker: true})
.then( () => map.fitBounds() );
});
var map = new mqgl.Map('map', 'KEY');
map.load( () => {
map.batchGeocode(['Denver, CO', 'Boulder, CO', 'Fort Collins, CO'])
.then( points => points.forEach(
(point, key) => map.icons.marker.add(point)
))
.then( () => map.fitBounds() );
});
Multiple locations to be geocoded. Advanced Location Objects are also supported.
['Washington, DC', 'New York, New York']
{
locations: [
{
street: '1555 Blake St',
city: 'Denver',
county: 'Denver',
state: 'CO'
},
{
city: 'Boulder',
state: 'CO'
}
]
}
In addition to the options from the Batch Geocoding API, the "addMarker" option (boolean, default is false) determines if a marker should be added after each location is geocoded.
A Promise, consisting of an array of geocoding objects: [{lng, lat}, {lng, lat}]
Converts a pair of geocodes into an address. Optionally adds a marker on the map.
var map = new mqgl.Map('map', 'KEY');
map.load( () => {
map.reverseGeocode([-105.122870, 39.666076], {addMarker: true})
.then( () => map.fitBounds() );
});
A single geocode to be reverse geocoded.
[-105.12287074707808, 39.66607663574351]
In addition to the options from the Reverse Geocoding API, the "addMarker" option (boolean, default is false) determines if a marker should be added after the location is geocoded.
A Promise, containing the reverse geocoding response object.