Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Places API

I want to develop an application in which i want to display information about places nearby (within 1km )the user by getting its current location..

Say for example i want to display information about Restaurants, Shopping Malls, Hospitals located within 1km related to current location of the android device..

I have gone through this link : Using Google Places API in Android.. But didnt get more.

Have anyone used Google Places API in android ?

like image 475
Kartik Domadiya Avatar asked Apr 05 '11 11:04

Kartik Domadiya


People also ask

Is it free to use Google Places API?

Places API is not free, however, once you set up your billing account, you will be entitled for a one time $300 free credit(usable for Google Cloud Platform products) and a monthly recurring $200 free credit(exclusive for Google Maps Platform products), after consuming the credits, you will receive an OVER_QUERY_LIMIT ...

How do I use Google Places API for location analysis and more?

Once you've made an account and are on the Google Cloud platform, you'll want to go to use the drop down navigation in the top left and choose API & Services > Credentials. Once there, you'll want to hit Create Credentials on the top followed by API key.


2 Answers

Some points to keep in mind:

  • In order to use Google’s Places API, you will need to register and obtain a Google Map’s API Key.
  • In class UrlSigner in the tutorial the variable descriptions are: keyString => is your Google Map api key. urlString is the url you want to sign using the api key.
  • In code you will find inputKey and inputUrl. these 2 variables are just for testing purpose you can omit them if you want. You can directly write code as follows:

    URL url = new URL(urlString);

    UrlSigner signer = new UrlSigner(keyString);

    String request = signer.signRequest(url.getPath(),url.getQuery());

    System.out.println("Signed URL :" + url.getProtocol() + "://" + url.getHost() + request);

in main method of UrlSigner class.

like image 147
Harry Joy Avatar answered Oct 11 '22 03:10

Harry Joy


The API works well in India(of-course will work anywhere in the globe). What you must go through is Google Places API. You can simply give a url request to google with user's current location and place-types that you would prefer.

The response may be either XML or Json as per your request. All you have to do is parse it out. You can get places around you upto 50 kms. An example for url request is

https://maps.googleapis.com/maps/api/place/search/xml?location=9.934866,76.267235&radius=50000&types=country%7Cairport%7Camusement_park%7Cbank%7Cbook_store%7Cbus_station%7Ccafe%7Ccar_rental%7Ccar_repair%7Cchurch%7Cdoctor%7Cfire_station%7Cfood%7Chindu_temple%7Chospital%7Clawyer%7Clibrary%7Cmosque%7Cmuseum%7Cpark%7Cparking%7Cpharmacy%7Cpolice%7Cpost_office%7Crestaurant%7Cschool%7Ctrain_station%7Czoo&sensor=true&key=your_API_Key 

*Note: %7C is just "|".

like image 37
Deepukjayan Avatar answered Oct 11 '22 04:10

Deepukjayan