2

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
theGame
  • 383
  • 4
  • 6
  • 18

2 Answers2

1

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.

Robot Woods
  • 5,677
  • 2
  • 21
  • 30
  • i just want to search near by location e.g. pizzas schools etc in a 10km diameter, can it be done by this place search? – theGame Jul 25 '11 at 15:43
  • well, you can search by `type` (schools is in the list of options, as is food) but for pizza (or any free-text) I think you'd have to use the `name` variable, which may not give a FULL response (ie Joe's Pie Shack might not be in the results...) read through that link and this one: http://code.google.com/apis/maps/documentation/places/supported_types.html – Robot Woods Jul 25 '11 at 15:55
0

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

Juan Pablo
  • 1,213
  • 10
  • 15
  • radarsearch has been discontinued :( https://stackoverflow.com/questions/45398308/alternative-to-google-maps-api-radar-search – Dan Fiorino Dec 09 '19 at 15:41