Reputation: 393
I was wondering if we could get nearby location by giving the radius parameter around a fixed point. Say i want to get nearby locations only in 10km diameter of a particular location.
Can i do this using google api? or
i have to use some thing else for this?
Upvotes: 2
Views: 7728
Reputation: 1223
You have 2 aptions to search 1) Nearby search returns complete information of each place but it returns up to 20 results on each query and if more places available, it returns a "next page" token.
url="https://maps.googleapis.com/maps/api/place/nearbysearch/json?location="+lat+","+long+"&radius=" +radius+"&types=" + types + "&key=<PUT_YOUR_API_KEY_HERE>";
lat and long are your center coordinates. radius is measured in meters and is a value up to 50000. types is the type of Place you are searching according to this listing: https://developers.google.com/places/supported_types . Example: "atm"
2) Radar search that returns a reduced set of information of each place but it returns up to 200 on each query
url="https://maps.googleapis.com/maps/api/place/radarsearch/json?location="+lat+","+long+"&radius=" +radius+"&types=" + types + "&key=<PUT_YOUR_API_KEY_HERE>";
lat and long are your center coordinates. radius is measured in meters and is a value up to 50000. types is the type of Place you are searching according to this listing: https://developers.google.com/places/supported_types . Example: "atm"
You have more options to search, keyword & name appart from type.
You can have your results on xml or json format.
Full definition of nearby and radar search is here: https://developers.google.com/places/web-service/search
Upvotes: 0
Reputation: 5687
from: http://code.google.com/apis/maps/documentation/places/
"Certain parameters are required to initiate a Place Search request. As is standard in URLs, all parameters are separated using the ampersand (&) character. The list of parameters and their possible values are enumerated below.
-location (required) — The latitude/longitude around which to retrieve Place information. This must be provided as a google.maps.LatLng object.
-radius (required) — The distance (in meters) within which to return Place results. The recommended best practice is to set radius based on the accuracy of the location signal as given by the location sensor. Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.
Upvotes: 1