Hello! I want to retrieve all objects related to a category, but the search result returns 0 objects.
My code:
var locatorTask = new LocatorTask(new Uri("https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"));
GeocodeParameters param = new GeocodeParameters();
param.MaxResults = 100;
if (map.VisibleArea != null)
param.SearchArea = map.VisibleArea;
else return;
param.MinScore = 1;
param.ResultAttributeNames.Add("*");
param.Categories.Add("POI");
param.Categories.Add("13035");
param.Categories.Add("Coffee");
var res = await locatorTask.GeocodeAsync("", param);
foreach (var item in res)
{
TXTstat.Text = $"{TXTstat.Text}{item.Attributes["PlaceName"]}\n";
}
Well, the 1st param for GeocodeAsync() is an address and you're not supplying any. https://developers.arcgis.com/rest/services-reference/enterprise/geocode-service/
Hi,
I have edited code from the Find Place sample (MAUI). Code below:
GeocodeParameters parameters = new GeocodeParameters();
// Get the current map extent.
Geometry extent = MyMapView.VisibleArea;
// Update the search parameters.
parameters.SearchArea = extent;
var locatorTask = new LocatorTask(new Uri("https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"));
// Get the location information.
IReadOnlyList<GeocodeResult> locations = await _geocoder.GeocodeAsync("Coffee", parameters);
// Stop gracefully and show a message if the geocoder does not return a result.
if (locations.Count < 1)
{
return; // 3. Stop.
}
It works and returns locations. Sample is here: