I am using the Geocoder class in android studio and I am able to get country name and address by doing
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (addresses != null && addresses.size() > 0) {
userCountry = addresses.get(0).getCountryName();
userAddress = addresses.get(0).getAddressLine(0);
}
What I want to do now is to categorize the location. Let`s say if I'm near a park I will translate the latitude and longitude to "park" or if I'm at the beach it will categorize the location as "beach". Is there anything I can use to categorize these places automatically using longitude and latitude?
I thought maybe
addresses.get(0).getLocality()
but it just gives me city name
and when I tried
addresses.get(0).getFeatureName()
it just gives me a number so I'm not sure what that number is.
You could use your longitude and latitude along with Google Places API .
Through the API you will be able to tell if a user is near a city-based location such as a gym or a park.
You can find more information about this API here .
Geocoder can't give you the types.
Also, geocoder isn't avaiable on all devices.
Instead, I would recommend to use the Google Geocoding API.
It returns types of places along with their names. For more information, read here: https://developers.google.com/maps/documentation/geocoding/intro
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.