I posted this issue in the user forums for the Xamarin beta, but got no response. Unfortunately I'm still seeing the same issue in the latest release. Is this a bug, a potential issue with my locator, or is there a workaround? I basically need the ability for my users to click on the map and return the address at that location. The locator was created in 10.3.1. Not sure if that matters, but like I say below it works fine for normal locates.
" I'm working with a locator creating tools to both search for an address and return the address for a clicked location. The address search works like a charm, but I'm getting some weird results in the reverse geocode process. When I check the LocatorInfo.ResultAttributes and SearchAttributes properties on the LocatorTask I get a list of all the attributes I'm expecting to have access to in the GeocodeResult object that comes back from the reverse geocode call. There are no attributes present in the GeocodeResult.Attributes property for the result that comes back. It's these attributes that I use to communicate the address at that location to the user.
This seems to be a bug of some sort. The documentation for the ReverseGeocodeParameters.ResultAttributeNames property seems to indicate that you should be able to set that, but at this point you can only get that information and it is an empty collection as well. Can someone at Esri confirm that this is an issue or point me in the right direction here if I'm off base?
Thank you ... "
I created a 10.4.1 locator and still have the same problem. Can someone at Esri confirm whether or not this is a bug? I can supply my locator so you can repro the issue if need be.
Just for everyone's information, Esri has acknowledged that this is a bug. They were able to get the proper information from a reverse geocode against their online locator, but not from an offline locator.
I've just received a valid workaround from Esri on this bug. You need to have that last line of code in there when you specify your reverse geocode parameters. Esri admits we shouldn't have to do it and will be fixing it in a future release, but at least we have a way forward.
ReverseGeocodeParameters rgParams = new ReverseGeocodeParameters();
rgParams.MaxDistance = 10;
rgParams.OutputSpatialReference = MyMapView.Map.SpatialReference;
rgParams.MaxResults = 5;
The default return fields for an ArcGIS Runtime locator dataset are currently only Match_addr for a non-composite locator, and Match_addr and Loc_Name for a composite locator. To return additional fields, field names should be added to the ReverseGeocodeParameters.ResultAttributeNames property as you described above. Or an asterisk ("*") can be used to return all fields, as above.
I've submitted an enhancement request for providing the ability to add publisher-defined default return fields to ArcGIS Runtime Locators.