geothermie-atlas/app/utils/getAddress.js

18 lines
486 B
JavaScript
Raw Permalink Normal View History

2023-10-19 09:07:33 +00:00
import * as locator from '@arcgis/core/rest/locator';
// reverse-geocode address for a given point
export default function getAddress(mapPoint, setAddress) {
const serviceUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer';
const params = {
location: mapPoint,
};
locator.locationToAddress(serviceUrl, params).then(
function (response) {
setAddress(response.address.split(','));
},
function () {
setAddress([]);
}
);
}