> nohup _

Using Google Places API in your location-aware application

Google publicly released their Places API today during the Google I/O Developer Conference in San Francisco. This makes it simple to query Google Places information for location-aware applications.

[Screenshot: Google Places API shows Restaurants in Paris]I've coded up a quick demo here. When you load the page, your IP address is passed to GeoLite City, a free GeoLocation database offered by MaxMind. The call returns your latitude, longitude, city, region and country, which is displayed in the top right-hand corner of the page.

The latitude and longitude returned by GeoLite City is in turn passed to Google Places API, which returns the location of restaurants within 500 metres of your own location. (Alternatively, enter the desired latitude and longitude directly.)

City Sample IP address Latitude Longitude
Brooklyn, USA 40.6525 -73.9554
Paris, France 48.8667 2.3333
Rio de Janeiro, Brazil -22.9 -43.2333
Sydney, Australia -33.8833 151.2167
Beijing, China 39.9289 116.3883
Johannesburg, South Africa -26.2 28.0833

Places of worship in Brooklyn

Change the Place type from Restaurant to one of the other types offered by the Places API - for example, Places of Worship. Then change the range from 500 metres to say, 1000 metres, to change the radius of search.

Change the IP address to see how you can jump from one continent to another. Notice how the City, Region and Country information is updated in the top right-hand corner.