Prasad Rajapaksha
Prasad Rajapaksha

Reputation: 6190

Find addresses within given radius

I have a requirement to find all the addresses within given radius. I have implemented following to get done this.

Google Places API

This only provide business addresses within the radius.And it accept radius as a parameter. https://maps.googleapis.com/maps/api/place/textsearch/json?key=myAPIKey&location=6.914701,79.973085&radius=100&sensor=false&hl=en&query=*

Google reverse geocoding

It's just converting given lat & lng to addresses. This doesn't actually meet my requirement.And it is not accepting radius as a parameter. http://maps.googleapis.com/maps/api/geocode/json?latlng=6.914701,79.973085&sensor=false

Is there any way to get all addresses within given radius. Specially resident addresses.

Upvotes: 7

Views: 13531

Answers (2)

Cybercartel
Cybercartel

Reputation: 12592

You can brute force the google map api for example you can use an interval of points for example every 8° degree within a certain radius and evaluate the json response from the Google maps geocode API. But the Google map geocode API doesn't support the same feature like the places API because of good privacy reasons. Read here about a similar question: Map of all points below a certain time of travel?.

Upvotes: 3

scai
scai

Reputation: 21509

Have you considered using OpenStreetMap for your task? With the help of the Overpass API you can query for all data within a given bounding box. For example this query returns all addresses which have a house number within your mentioned area. It uses the overpass turbo for visualization and the Overpass API only in the background but of course you can also use the Overpass API directly for returning raw data as XML or JSON.

However because your area has only sparsely mapped house numbers in OSM, there isn't much to return yet. Other better mapped areas will work way better but you can try to improve your area if you want.

For more information about how to modify the given query take a look at commonly used tags and the Overpass API language guide.

Upvotes: 16

Related Questions