nativescript-community / geocoding

Provides access to native geocoding APIs for NativeScript apps (android.location.Geocoder for Android, CLGeocoder for iOS).
8 stars 1 forks source link

return all resulted locations #1

Closed farfromrefug closed 5 years ago

farfromrefug commented 5 years ago

You should return all resulted locations and not only the first one. Very useful when doing location search

timdoege commented 5 years ago

New functionality added to allow retrieval of multiple hits. Note, however, that the APIs on Android and iOS usually only return a single hit. The docs for each platform:

Android implementation

Returns an array of Addresses that are known to describe the named location, which may be a place name such as "Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code such as "SFO", etc.. The returned addresses will be localized for the locale provided to this class's constructor.

The query will block and returned values will be obtained by means of a network lookup. The results are a best guess and are not guaranteed to be meaningful or correct. It may be useful to call this method from a thread separate from your primary UI thread.

Parameters locationName String: a user-supplied description of a location maxResults int: max number of results to return. Smaller numbers (1 to 5) are recommended

iOS implementation

Depending on the precision of the user-provided information, you may receive one result or multiple results. For example, passing a string of "100 Main St., USA" may return many results unless you also specify a search region or additional details. To help you decide which result is correct, the geocoder actually returns CLPlacemark objects, which contain both the coordinate and the original information that you provided.