Pages

Thursday 17 May 2012

Google Places API



“Google Places API” (GPA) along with “Google Directions API” (GDA) is quite a strong tool developers can use at their wish. The primary need for “Google Places API” is to get a unique authentication key for each app. The keys are of two types:

1. used for development purpose
2. used for a wide release
The key that is used for development purpose allows only a limited number (1,000 requests) of hits per day, whereas the later allows almost any number of hits (to be precise 100,000 requests).
In GPA, “Place Request” gives a response usually called as “Place Request Response”. This response can be obtained both in JSON and XML formats. Once you obtain a result, the rest is quite simple. Just parse your result (either XML or JSON) and show them in a map. That is all the user needs.
In the “Place Request Response” there are certain tags we should give due importance.

<status>
<status> will give a result from which we may know if our result is a success, a zero result response  or other critical results such as invalid request, over query limits, etc.

<type>
This specifies the type of place.

<name>
This gives the place name.

<reference>
This tag should be given greater importance since the very long string it gives in response can be used to retain all its place details such as its address, international phone number, etc.
The reference string Google give as a response for the “Place Request Response” can be used for “Place Detail Request”. The result for this request consists of everything that Google knows about that place.
These are all one needs for a quick start with “Google Places API”. But as you start serious coding, it’s better to read Google’s documentation thoroughly.
Now let’s move on to “Google Directions API”. Something very funny about GDA is that it doesn’t need an API key.
GDA is a strong tool that would help us to plot routes from a starting point to a destination point. This API is so powerful that it would give us instructions like “turn left from here”, “go straight through the junction”, etc. In RW blogs, he used to say it’s better to show the code than talk too much about it. I would follow the same here. Here is the best and simplest implementation of GDA. Go through the code and GDA is all yours.


That’s all for now!

No comments:

Post a Comment