Saturday, March 19, 2011

Easier way to use Google Latitude

 Click Like If you Agree
Hi Everyone ,

My first post was about getting the Location using Google Latitude Api using OAUTH,

it is extremely useful when you want to create an application that gets your app users

location and you can mashup with google maps api or yahoo maps to create killer apps .

But if you are creating a system in which you create google latitude account for your

customers  or you want to track your kids from your home , there's  a simpler method

 for doing that , a shortcut rather than going the OAUTH way i.e. Google Latitude Badge .

Step 1

Log into your google account through which you are linked to Google Latitude

Step 2


Enable your google public location badge account by selecting the radio button .

Step 3

So once the basic steps are done you are ready for using the Google Latitude Badge

Paste this url onto your browser and you can see how the json response is .

You will get a response like

{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [-73.2575225, 40.7758618]},
"properties": {
"id": "YOURID",
"accuracyInMeters": 2380,
"timeStamp": 1289029283,
"reverseGeocode": "Brentwood, NY, USA",
"photoUrl": "",
"photoWidth": 96,
"photoHeight": 96,
"placardUrl": "",
"placardWidth": 56,
"placardHeight": 59

Depending on the server side language you are using you can retrieve your results

accordingly . However I will be showing you how to get the results in php .


//Replace the YOURUSERID in the url below with your Badge userid . 

// We get the content
$content = file_get_contents( $url );

// We convert the JSON to an object
$json = json_decode( $content );

$coord = $json->features[0]->geometry->coordinates;
// this will give you the coordinates of the user
echo $coord ;
$timeStamp = $json->features[0]->properties->timeStamp;
// timestamp of the last update
echo $timestamp ;

// If you want to retrieve the longitude & latitude separately


echo "Your current coordinates  Latitude :".$latitude."  Longitude".$longitude ;


You can further mashup with the google maps api to show the location

on the google maps .


About This Blog

This Tech Blog is about a month old and increasing
number of pageviews and a steady increase in
our loyal readers has prompted us in writing
unique articles that will be of great use to all the
webmasters .The blog currently has only 15+
unique google tricks and hacks , we will be adding
new tricks as and when we stumble upon something
useful to our readers .

  © Blogger templates The Professional Template by 2008

Back to TOP