Anthony Graglia
Anthony Graglia

Reputation: 5435

Getting business names or landmarks from lat/long in Android

Ok, so I have been searching for quite some time on this.

I have a lat/long from my new found location. geocoder's getFromLocation returns a certain number of addresses from the lat/long and that is all fine and dandy. I then put it into an adapter which populates a spinner... also works perfect.

What I need now though is to get business names instead of addresses. I would prefer to use the lat long and get all businesses within a certain distance because not all the addresses returned from getFromLocation are complete. Some are just neighborhoods or countries.

This link does a good job although I have not implemented it yet. In my mind, it seems like a lot of processing power for what should be pretty standard from a big-wig like Google.

http://www.smnirven.com/?p=39

Thanks in advance.

public void getFeature() {
    double lat = currentLocation.getLatitude();
    double lon = currentLocation.getLongitude();
    Geocoder gc = new Geocoder(getBaseContext(), Locale.getDefault());

    try {
        List<Address> tmpfeatures = gc.getFromLocation(lat, lon, 15);
        Iterator itr = tmpfeatures.iterator();
        while (itr.hasNext()) {
            featuresAdapter.add(((Address) itr.next()).getFeatureName().toString());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Upvotes: 4

Views: 6352

Answers (1)

Chris Broadfoot
Chris Broadfoot

Reputation: 5112

Google Places API. Sign up for the developer preview.

https://developers.google.com/places/documentation

Upvotes: 2

Related Questions