Extends L.esri.
L.esri.
is an abstraction for submitting requests for address candidates associated with a particular location. You can find more information and the source code for this plugin here.
Constructor
Constructor | Description |
---|---|
L.esri. | Creates a new Reverse task. |
You can pass any options you can pass to L.esri.Task. The url
will be the ArcGIS geocoding service by default but a custom geocoding service can also be used.
Methods
Method | Returns | Description |
---|---|---|
latlng( | this | The L. object for which an associated address will be queried. |
distance( | this | The distance (in meters) around the point for which addresses will be queried. The default value is 100 . |
language( | this | The language to use when returning address candidates. |
intersection( | this | Set this value to true if you'd like the nearest intersection to be returned (Default value is false ). |
run( | XML | Executes the request chain and accepts the response callback. |
Examples
map.on("click", function (e) {
L.esri.Geocoding
.reverseGeocode({
apikey: accessToken
})
.latlng(e.latlng)
.run(function (error, result) {
if (error) {
return;
}
layerGroup.clearLayers();
const marker = L.marker(result.latlng).addTo(layerGroup);
const lngLatString = `${Math.round(result.latlng.lng * 100000) / 100000}, ${Math.round(result.latlng.lat * 100000) / 100000}`;
marker.bindPopup(`<b>${lngLatString}</b><p>${result.address.Match_addr}</p>`);
marker.openPopup();
});
});