Hi,
I'm trying to figure how to do reverse geocoding that will allow me to specify the exact object type I'd like to reverse geocode against. For example, in the rest api there is URL paramter for featureTypes = PointAddress. I don't want to reverse geocode against the street segment, just address points. I can't see this type of parameter in the JS API 4.14. I only see the location and locationType parameter in the API docs. Below is a sample block of code.
let params = {
location: evt.mapPoint,
locationType: "rooftop"
};
geocoder.locationToAddress(params, options)
.then(function(response) { // Show the address found
console.log(response.attributes)
// values to access to actual address value
var address = response.attributes.Address + ', ' + response.attributes.City + ', ' + response.attributes.Region + ', ' + response.attributes.Postal;
showPopup(address, evt.mapPoint);
}, function(err) { // Show no address found
showPopup("No address found.", evt.mapPoint);
});
}
});
Solved! Go to Solution.
Currently, featureTypes is not available as a parameter of the locationToAddress() method, but we are considering adding it at a later release. One alternative would be to add this parameter to the request using requestInterceptor.
doc: RequestInterceptor
Currently, featureTypes is not available as a parameter of the locationToAddress() method, but we are considering adding it at a later release. One alternative would be to add this parameter to the request using requestInterceptor.
doc: RequestInterceptor
Thanks Noah,
Appreciate the feedback I'll give the request interceptor a try!
Noah Sager definitely able to get it to work for one feature type:
esriConfig.request.interceptors.push({
urls: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",
before: function(params) {
params.requestOptions.query.featureTypes = "PointAddress";
}
});
Just curious if we can set multiple feature types.
Thanks!
Dara