Siddhpura Amit
Siddhpura Amit

Reputation: 15128

Google place api, wants to get nearest location

Hello I want to search nearest location using google place api....

from https://developers.google.com/places/documentation/supported_types i have used types in my code for searching nearest places....

and the code is below

try {
     double radius = 5000; // 10000 meters
    // get nearest places
    nearPlaces = googlePlaces
                    .search(gps.getLatitude(), gps.getLongitude(), radius,
                            "sublocality|sublocality_level_4|sublocality_level_5|sublocality_level_3|sublocality_level_2|sublocality_level_1|neighborhood|locality|sublocality");

    } catch (Exception e) {
    e.printStackTrace();
    }
 return null;
}

but could not find nearest places

like if i am in "San Diego, CA, USA" then i want to get result like

Gaslamp/Downtown,
Pacific Beach,
Ocean Beach,
Uptown,
Hillcrest,
Mission Valley, Fashion Valley,
North Park,

but instead of this i am getting only two value like

Mission Valley East,
Serra Mesa

so can any one help me what type i have to pass so i can get result like above instead of below result

Upvotes: 4

Views: 3494

Answers (3)

Chris Green
Chris Green

Reputation: 4425

My previous answer was deleted by a moderator for unknown reasons, I am re-posting with some more context as it is the currently the correct answer:

It appears you are trying return nearby geographical locations (anything from the second list in the supported place types). Unfortunately the Places API is not designed for this, it is designed to return a list of nearby establishments (anything from the first list in the supported place types) and up to two locality or political type results to to help identify the area you are performing a Place Search request for.

This is stated in the documentation here: https://developers.google.com/places/documentation/search#PlaceSearchResponses

"results" contains an array of Places, with information about each. See Place Search Results for information about these results. The Places API returns up to 20 establishment results per query. Additionally, political results may be returned which serve to identify the area of the request.

If you type filter your Place Search request by a geographic location type like locality or political, you will filter out the establishment results and only be left with the area identity results.

A Places API - Feature Request for returning nearby localities has been filed here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4434

If you believe this would be a useful feature please make sure your star the request to let us know you are interested in seeing it added.

Upvotes: 5

praveenLal
praveenLal

Reputation: 94

You should consider the distance to maximum 50Km and there are different types as follows: establishment,lodging,spa,bar,church,place_of_worship etc.

Upvotes: 0

david strachan
david strachan

Reputation: 7228

double radius = 5000 is 5 Kilometers just over 3 miles. If you increase the radius you should return more places

Upvotes: 0

Related Questions