let params = AGSGeocodeParameters()
params.maxResults = 100
params.resultAttributeNames = ["*"]
params.outputSpatialReference = mapView?.spatialReference
params.searchArea = mapView?.visibleArea?.extent
params.minScore = 95
cancelable = locatorTask.geocode(withSearchText: searchText, parameters: params) { [weak self] results, error in
for result in results {
log.error("result score = \(result.attributes?["Score"])")
}
}
I am using the code above to get matched [AGSGeocodeResult]. And I see:
❤️ ERROR | 2017-06-06 18:31:08.9130 | result score = Optional(95.5)
❤️ ERROR | 2017-06-06 18:31:08.9150 | result score = Optional(94)
❤️ ERROR | 2017-06-06 18:31:08.9180 | result score = Optional(94)
❤️ ERROR | 2017-06-06 18:31:08.9200 | result score = Optional(92.8)
❤️ ERROR | 2017-06-06 18:31:08.9220 | result score = Optional(92.8)
❤️ ERROR | 2017-06-06 18:31:08.9230 | result score = Optional(92.8)
So it's probably an issue with AGSLocatorTask? And what is default value for the AGSGeocodeParameters.minScore parameter?
Thank you for your question! The `minScore` property on `AGSGeocodeParameters` is for offline geocoding only. For online geocoding, `minScore` has no effect. The default value is 0.
A couple of quick tips: The `AGSGeocodeResult` object has a `score` property, so you don't need to access the attributes to get at the score:
print("result score = \(result.score)")
Also, if you want to filter results based on the minScore, you can do this:
let filteredResults = results.filter { $0.score >= params.minScore }
I will get the doc updated to avoid future confusion.
If you have any more questions, let us know!
Mark
Thanks for the reply. Do you have an idea on why occasionally I receive less search results when I increase map's extent (visible area)? As an user I expect to receive more results when I zoom out, but in some cases receive less results (was 5 results with smaller extent and left only one after zooming out). My assumption was that the min score gets decreased and a result with low score gets filtered out but you say that the default min score is 0 and not used in the `online` geocoding.