This title must sound very ironic given that the whole purpose of Google Latitude is to reduce privacy. I am not saying this is a bad thing, just that telling people where you are right now is less private than not telling them.
Recently, Google took the reduction of privacy a little further by allowing you to setup a web site badge for Latitude. Up until this point, you could only share your location with select friends, however, now you can share it with the whole world via your website, blog, etc. I do use this, so you can spy on my location if you wish.
But to the privacy elements shall we… When you generate a badge, Google gives you a snippet of HTML code that looks like this:
<!-- Google Public Location Badge --> <iframe src="http://www.google.com/latitude/apps/badge/api?user=1234567890&type=iframe&maptype=roadmap" width="180" frameborder="0" height="300"></iframe> <!-- To disable location sharing, you *must* visit http://www.google.com/latitude/apps/badge and disable the Google Public Location badge. Removing this code snippet is not enough! -->
This works fine as is if you place it on your site, however, that number there (1234567890) is actually your API “username” and given inspecting this from your site, any user could simply place your position on their site or access the API by other programmatic methods. Notice Google’s warning that to disable it, you have to disable the badge globally via their site, but what if you just don’t want some people using your badge or plan to put it on a password protected area of your site… This is where a little privacy can help.
What I did for my site is use some PHP code to add a layer of abstraction to the Google Latitude API. It requests the content server side and displays it without ever revealing my Latitude user id. I then include my own PHP page within an iframe just as i would have the Google snippet and that’s it. Here is the simple PHP code to do this:
<?php $url = "http://www.google.com/latitude/apps/badge/api?user=1234567890&type=iframe&maptype=roadmap"; $content = file_get_contents($url); print $content; ?>
The resulting PHP page will generate a map that fills the entire browser. Then simply add an iframe that references that PHP script and your desired width and height and boom, no one can inspect your user id and you have added a little privacy back to Google Latitude.
<iframe src="location.php" width="650" frameborder="0" height="480"></iframe>
P.S. For the advanced users out there you can also do some creative things with the “$content” object within PHP such as inject your own CSS or even remove elements of the badge that you don’t want on your site since Google gives very limited customization to this.