Latitude Public Location Widget

10 years, 10 months ago

(0 comments)

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).

Comments

  • There are currently no comments

New Comment

required
required (not published)
optional