Remove "unnamed road" from geocoder result

Viewed 22

How do I Remove "unnamed road" from geocoder results? I want this to apply to all languages, not just English

Current code returns unnamed road in other languages such as German ("unbenannte Straße")

val geocoder = Geocoder(this, Locale.ENGLISH)
val addresses: List<Address>?
addresses = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1)
1 Answers

This doesn't provide a full implementation, because I can't test it at the moment, but would be too long for a comment.

  1. Find some coordinates such that geocoder.getFromLocation(latitudeUR, longitudeUR) whose address contains "Unnamed road". Perhaps using something like geocoder.getFromLocationName("... Unnamed road ...", 1)[0].

  2. Find in English where exactly "Unnamed road" occurs in the resulting Address.

  3. Now from geocoderOtherLocale.getFromLocation(latitudeUR, longitudeUR) you can get "Unnamed road" for that language. Cache it so you don't need to repeat steps 1-3 each time.

  4. Now you can remove it from the results.

Related