- Home
- About
- My work
- Photoshop poster design
- Kaun banega crorepati game (kbc2) (download the game)
- Textoo : iPhone (and now Android) app to send free SMS using web gateways
- 3ds max animation
- Multi user avatar chat based flash website for Incident 09
- Video editing / post production / audio mixing
- Joomla real estate component built using ExtJS
- Facebook cricket betting application
- Swishmax projects & Flash website for Incident 08 using Swish
- PHP-Selenium Framework for UI Automation
- PHP based CMS with chat
- Twitter reputation score
- Downloads
- Contact
How to display your accurate google latitude location address with the public badge map in your blog
Google latitude is a great way to share your current GPS location with everyone. You can put up the google location badge on your blog and let the world know your exact geographical location.
But the latitude badge does not provide the exact address of your current location in terms of the area names but shows the exact location on the map. Google latitude badge shows only city level address along with the map. So I decided to write my own small PHP script to print out the exact address instead of an approximate one which is shown by default. You could use this code coupled with XMPP integration to show it as you google talk status message (a tutorial and script for this..sometime later)
Basically, instead of displaying “<City name>,<country>”, this script will display “<Road name>, <areaname>,<cityname>,<country>”
The internals : As soon as the script is executed, It uses the google latitude developer api to get your current co ordinates, then it makes use of the google maps v3 geocoding api (previously called reverse geo coding) to get the info about the co-ordinates of your current location which includes the street name/road name etc.
Steps to add this cool thingy onto your own site:
1. Install google maps application on your GPS mobile phone having GPRS connection (symbian s60,iphone,android) and then enable Latitude inside google maps app. Ensure that detect location is selected inside the latitude settings under google maps.
2. Goto google latitude web page (http://www.google.com/latitude/apps/badge) and select Enable and show best available location.
3. In the javascript embed code section of the badge config page, select zoom level automatic, and choose the map type, size of map.
4. Put the generated embed code on your blog to display the map and an approx city level address (we’ll fix this in a moment)
5. Now to display a more accurate address (which includes the roadname,streetnames, areanames) , extract the userid for latitude from the javascript embed code and put it in the below PHP code (line 2)
6.Add this PHP code into a file named “mylatitudelocation.php” and upload it into your webserver root.
7. Add this iframe code into your blog widgets sections to display the accurate address of your current location
<iframe src="mylatitudelocation.php" width="100%" height="50" frameborder="0"></iframe>
Here’s the PHP code:
<?php $latitudeUserid=”-4xxxxx….” // change this and insert your latitude user id (available from the public badge embed code ”
function ago($tm,$rcs = 0) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array(‘second’,'minute’,'hour’,'day’,'week’,'month’,'year’,'decade’); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v–); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .=’s'; $x=sprintf(“%d %s “,$no,$pds[$v]); if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); return $x; }
$latitudeAPI=”http://www.google.com/latitude/apps/badge/api?user=$latitudeUserId&type=json”;
$locationDetails=json_decode(file_get_contents($latitudeAPI)); $lat=$locationDetails->features[0]->geometry->coordinates[0]; $lng=$locationDetails->features[0]->geometry->coordinates[1]; $timestamp=$locationDetails->features[0]->properties->timeStamp; $when=ago($timestamp);
$latlng=”$lng,$lat”;
$geocodeAPI=”http://maps.google.com/maps/api/geocode/json?latlng=$latlng&sensor=false”;
$locationDetails=json_decode(file_get_contents($geocodeAPI)); $locationString=$locationDetails->results[0]->formatted_address;
echo “$when ago, I was in $locationString”; ?>
Incoming search terms:
- how accurate is google latitude (44)
- maps google com latittude userid (17)
- javascript latitude to address (8)
- how accurate is google latitude? (7)
- google latitude show coordinates (6)
- google latitude get location by userid (5)
- how to insert name location in google map latitude (5)
- how accurate is google lattitude (4)
- google latitude php script (4)
- show your location on google map on your website (3)
accurate laitude address, blog, city, exact address, exact location, geocoding, google, google latitude, google latitude api, google maps, google maps api, google public location, gps location, how accurate is google latitude, iphone, javascript embed code, json, level, location, location address, lt road, mylatitudelocation, page, reverse geocoding, share your location, status message, time, timeStamp
Print article | This entry was posted by Kiran Kumar on July 10, 2010 at 12:12 pm, and is filed under Misc. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
KBC game : Kaun Banega Crorepati online flash game 2013
about 12 years ago - 2,206 comments
KBC game will load below Game requires Flash plugin 9 New KBC HTML5 game launched This was a simple game I created using SWiSH in 2005. The questions appear randomly with no logic for the levels of difficulty and the “Phone a friend” lifeline is a dummy lifeline with no real purpose. The game was hosted…
Textoo Pro ; in the works
about 13 years ago - 1 comment
July 17th 2011 : Textoo Pro now in the apple app store. Download it here : http://textoo.in July 10th 2011 : Textoo v2.0 renamed to Textoo Pro Release of Textoo Pro has been postponed to July 15th 2011 due to app store codesign issues. Here’s a sneak peek into the brand new version of Textoo…
Webcast Recording: Titanium for New Developers
about 13 years ago - 5 comments
Hi all, This is a recording of the webcast on Titanium for New developers ( a high level overview of Titanium architecture), hosted by Kevin Whinnery at Appcelerator Inc. This webcast was broadcast on 5th Jan 2011, 9am PST. Click here to view the webcast Incoming search terms:Titanium for New Developers webcast (7)titanium webcasts (3)titanium…
Java resource bundle modification to identify hardcoded strings
about 13 years ago - 1 comment
Was involved in the modification of the Java ResourceBundle class to make it optionally decorate all the strings coming from any specific resource bundle with certain special characters so that visual identification of hardcoded strings is possible.
27th Oct – Appcelerator Titanium Webinar Recording , questions and answers
about 13 years ago - 4 comments
Recording Watch the webcast recording for the Q&A session here Q&A Transcript These are the questions and answers which were posted during the Titanium webinar which took place on 27th Oct 2010 Q: Will Blackberry still be windows only? A: it’ll be mac when RIM adds a Mac simulator Audience Question Q: Does Titanium support…
Titanium Mobile vs Sencha Touch
about 14 years ago - 9 comments
I just tried out the sencha touch examples on the android 1.6 simulator and the performance is pathetic. Seems like google forgot to properly implement their javascript V8 engine onto their OS. Appcelerator’s Titanium Mobile and Sencha touch are 2 different frameworks which address a totally different set of audiences. Comparing them is like comparing…
Facebook cricket betting application
about 14 years ago - 4 comments
Developed a facebook app for placing virtual bets on cricket matches with teams made from your facebook friends. Made using PHP 5, ExtJS framework, Facebook API
Kaun banega crorepati game (kbc2) (download the game)
about 14 years ago - 300 comments
Update as of 5th June 2011 : Source code for the game has been published on this page. Now you can change the game as you wish, using Swishmax (www.swishzone.com) Update as of 20th Dec 2010 : I have been noticing quite a lot of visitors reaching this page through google search. So drop in…
3ds max animation
about 14 years ago - 4 comments
Playiing with reflection & refraction materials combined with smoke and particles became my new way to pass time. With help from the ’3dsmax 6 Bible’, I learnt a few basics. Here are some of the videos I rendered:
Photoshop poster design
about 14 years ago - 22 comments
I’ve been actively involved in design of a lot of print media in my college.Find all my photoshop posters, certificates, badges etc which I created for my college here.
about 13 years ago
Thanks man
about 13 years ago
but you probably should put a notice about thoe auto curly quotes in wordpress.
about 13 years ago
hey im trying to figure out if i can just get the city, state and time updated and nothing else. By that I mean no map and no other text. Any idea how i could do that? My server is a windows box with iis….
about 13 years ago
Thanks for the code, but it seems to be a bit broken.
I know it’s been a while but is there any chance you could clean it up and post it with the correct formatting so that a PHP amateur like me can make it work?
As mentioned above, i think your blog has changed some of your quote formatting.
There’s also a missing semicolon at the end of the line for the first variable $latitudeUserid
Thanks,
~Simo
about 13 years ago
Finally got it working, this is what that worked.
= 0)&&(($no = $dif/$lngh[$v])<=1); $v=$v-1)
if($v < 0) $v = 0;
$_tm = $cur_tm-($dif%$lngh[$v]);
$no = floor($no); if($no 1) $pds[$v] .='s';
$x=sprintf("%d %s ",$no,$pds[$v]);
if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm);
return $x; }
$latitudeAPI="http://www.google.com/latitude/apps/badge/api?user=".$latitudeUserId."&type=json";
$locationDetails=json_decode(file_get_contents($latitudeAPI)); $lat=$locationDetails->features[0]->geometry->coordinates[0]; $lng=$locationDetails->features[0]->geometry->coordinates[1]; $timestamp=$locationDetails->features[0]->properties->timeStamp; $when=ago($timestamp);
$latlng=$lng.",".$lat;
//$latlng=$lat.",".$lng;
$geocodeAPI="http://maps.google.com/maps/api/geocode/json?latlng=".$latlng."&sensor=false";
$locationDetails=json_decode(file_get_contents($geocodeAPI)); $locationString=$locationDetails->results[0]->formatted_address;
echo $when." ago, I was in ".$locationString; ?>
about 11 years ago
Hello! This is kind of off topic but I need some help from an established blog.
Is it very difficult to set up your own blog?
I’m not very techincal but I can figure things out pretty fast. I’m thinking
about setting up my own but I’m not sure where to begin. Do you have any points or suggestions? Cheers
about 11 years ago
This post is really a nice one it assists new the web visitors, who are wishing in favor of blogging.