Latitude Public Location Widget

11 years, 1 month ago


update nov 2013: uh, well, never mind. latitude is gone for good. the track your friends part of things has moved to g+, but a) no and b) there's no API anyway. i ended up rolling my own replacement using little fluffy location library for Android

On the homepage of this site is a Google Latitude badge showing where I am (or, if my phone isn't on or updating things, where I was some time ago). Getting your location (as well as location history data and other things) from the Google Latitude API requires oauth, and being as this was meant to be a quick afternoon project, this wasn't something I wanted to get into. Fortunately, the Google Latitude Public Location Badge, once enabled for either accurate or city-level location, can be used to get a location, its reverse-geocoded place name, and a timestamp.

The usual way to use this is to embed the "badge" html, which looks ok, but I wanted to control the way my badge looked and the way the timestamp was displayed. Fortunately, all the data in the badge is also available as json. I wrote a Django templatetag that requests the json and returns the attributes (lat/lon, placename, timestamp) used in the badge. I then use this to get a map from the Google Maps static API. You can see the templatetag code here.

Also featured: Django 1.4's humanize templatetags, in this case dayssince to give days since I was last seen (Today, Yesterday, or otherwise a date). There are a couple of other useful tags in this library, displaying things like human-friendly numbers (one, two, 1 million).


  • There are currently no comments

New Comment

required (not published)