Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I'm working on an article that seeks to find a certain type of business within my borough. Ideally I'd be able to supply a KML file and have it return only businesses within those bounds, but I'm not super optimistic that's possible and thus am settling for another approach: given a lat/lng set located in the centre of my borough, is there any way for either Google Maps or Earth (Or even Bing or OpenStreetMaps or whatever at this point -- I'm not picky) to return all businesses within a, say, 2.5 mile radius?

It seems like this is something Google Maps should be able to do; a query like "businesses Z near X,Y" does this somewhat (though it seems there's no way of defining what exactly "near" means). Any thoughts? Thanks!

share|improve this question
add comment

1 Answer

You can use the Google Places API to get at this data. It will allow you to specify a Lat/Long coordination and return places based on a radius distance. There is also documentation for Javascript based application.

Here's some info from the first article on using Place Search:

The Google Places API allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string. A Place Search returns a list of Places along with summary information about each Place; additional information is available via a Place Details query.

You will need to set up the API project in https://code.google.com/apis/console/ to get the required project key parameter.

Example request:

https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=<PROJECT KEY GOES HERE>
share|improve this answer
    
Not half bad. That said, specifying a location/radius only preferences results -- it doesn't eliminate results outside of that radius. –  aendrew Oct 19 '12 at 15:17
    
Really? According to the documentation the radius=xxx parameter should only return results within that distance. The list of business within that radius is then ranked by preference by default. Have you tried creating the request? Can you share it here to see what's going? –  OnenOnlyWalter Oct 19 '12 at 15:24
    
maps.googleapis.com/maps/api/place/textsearch/…; and maps.googleapis.com/maps/api/place/search/…; both yield similar results. Apologies in advance for the content; the hypothesis of the writer I'm working with is that there's a correlation between strip clubs and higher levels of crime (For the record, not sure I really agree with that). –  aendrew Oct 19 '12 at 15:30
    
I'm not entirely sure why, but /api/place/textsearch seems to return results independent of radius, you're right. However, /api/place/search/ does work. At least when I try to change the radius to 1000 it returns no results. Only when you expand to 4000 do you get anything. Even if it does limit results, are you saying the radial calculation is wrong? –  OnenOnlyWalter Oct 19 '12 at 15:43
    
Good to know re: search vs. textsearch. Doing a bit more fiddling, it seems regular search is working fine -- using Google Maps (as opposed to Google Earth's) measuring tool, all results are within 4000m. –  aendrew Oct 19 '12 at 15:52
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.