Christian Heilmann

Posts Tagged ‘geo’

Worldinfo – my Event Apart 10KB submission (information and documented source code)

Tuesday, August 17th, 2010

As you might know, an Event Apart in association with Microsoft are currently running a competition asking developers what they can do in under 10KB and I thought I have a shot at that.

So here’s my submission: an interface to get information about any country on this planet in under 5K:

I got the idea last Thursday during Pub Standards in London when someone asked me if it is possible to get information about all the countries in the world using YQL. The main interest was not only to get the names but also the bounding box information in order to display maps with the right zoom level. And it is, all you need to do in YQL is the following:

select name,boundingBox from geo.places.children(0) where
parent_woeid=1 and placetype=”country” | sort(field=”name”)

This gets all the children of the entry with the WOEID of 1 (Earth, that is) in the GeoPlanet dataset that are a country and sorts them alphabetically for you.

Each of the results comes with bounding box information which you then can use to display a map with the Open Streetmap static image API (or any other provider). For example:

http://pafciu17.dev.openstreetmap.org/?
module=map&bbox=38.804001,37.378052,
48.575699,29.103001&width=500&height=250

Or as I use it:

var image = ‘http://pafciu17.dev.openstreetmap.org/?module=map&bbox=’+
bb.boundingBox.southWest.longitude+’,’+
bb.boundingBox.northEast.latitude+’,’+
bb.boundingBox.northEast.longitude+’,’+
bb.boundingBox.southWest.latitude+
‘&width=500&height=250’;

The last piece to the puzzle was where to get country information from and of course the easiest is Wikipedia. Every country web site in Wikipedia has a info table about it which turned out to be too much of a pain to clean up so all I did was to scrape the first three paragraphs following this table with YQL:

select * from html where
url=”http://en.wikipedia.org/wiki/Christmas_Islands”
and xpath=”//table/following-sibling::p” limit 3

The rest, as they say, is history. I built the system in all in all 2 hours and now I spent some time to clean it up and spice it up:

World Info - my 10kb app compo entry (spiced up source version) by photo

As the first loading of the data takes a long time I use HTML5 local storage to cache the country information. This means you only have to wait once and subsequently it’ll be much faster.

You can download and see the source of Worldinfo on GitHub and read through the massive amount of comments I left for you.

If I were to build this as a real product I would cache the results on a server rather than hammering the APIs every time a user comes along – as the information doesn’t change much this makes much more sense. I will probably release a PHP version of that soon. For now, this is what we have.

Geo this! A Chrome plug-in to turn any web site into a map

Wednesday, July 21st, 2010

I’ve just started playing with Google Chrome Extensions heavily inspired by Mark Wubben’s talk at SWDC and of course the first thing I build is something to do with geographical locations.

Geo This! adds a little Earth icon to Chrome that, when pressed, analyses the page and shows a map of the locations it found in the text. If you highlight a part of the page first you only get the locations in this section. Click the screenshot below to go to the download site:

Geo This! A chrome plugin to turn any web site (or highlighted text) into a map

You can also see the extension in action in the following screencast:

Under the hood the extension is more or less a port of my addmap.js hack which in turn works most of its magic by using Yahoo Placemaker and YQL. The source code of the extension is available on GitHub.

Things that will come in future versions are:

  • Fixing the problem that Google Maps only numbers the first 10 markers on the static maps APIv1.0
  • More details on the found locationsv1.0
  • Ability to save the map and locations as an image
  • Better icons (anyone can paint me one?) – right now I am using one of the Project Icons by Mihaiciuc Bogdan and cruelly resized it in Skitch

What do you think?

Yahoo Placefinder – and an explorer interface for it

Thursday, June 24th, 2010

Yesterday Yahoo released another geo API - Yahoo Placefinder which is gives you street level information about the world.

The API is pretty straight forward and has some cool features like street crossing information and nearest airport features. To give you an idea of what the API returns, I created a small explorer hack:

Placefinder Explorer

You can download the explorer on GitHub in case you want to play with it yourself.

FOWA Dublin – Powerful Tools that You Need (and Probably Don’t Know About)

Sunday, May 16th, 2010

Last Friday I was up in Dublin at the Future of Web apps and gave my talk “Powerful Tools that You Need (and Probably Don’t Know About)”. I took FOWA as an opportunity to (re-)introduce the audience to some of the tools Yahoo offers and to brand the drive of developers to do everything by themselves instead of using already built solutions as ineffective.

The slides of my talk are available on SlideShare:

The audio of the talk is on Archive.org:

The video of the talk is available on Ustream:

Here are the resources I talked about as links:

Also check the YDN blog in the next few days for a full FOWA report.

GeoPlanet Explorer – another showcase for quick development with YQL and YUI

Friday, February 26th, 2010

A few days ago Gary Gale pinged me on messenger and subsequently carried a cup of coffee to my desk to pester me with another challenge. This time he talked about just how rich and cool the GeoPlanet data is and that it is tough to show people this in a simple interface. Internally we have a few pretty cool tools for testing and analyzing the data but most of them are too loaded with information only understandable for the geo folk out there. So in essence, the benevolent overlord of geo technologies in Yahoo was asking to build a simple interface to navigate the GeoPlanet data.

Well, this morning I got a chance to have a go at his request and here’s the GeoPlanet Explorer interface for you. Check the following screencast to see it in action:

Building the interface wasn’t magic – I used YQL to access the data, write a few lines of PHP to display it in a nested list and then added a few lines of YUI3 JavaScript to collapse and expand the location details.

Notice that the whole interface uses progressive enhancement throughout. If you have no JavaScript at your disposal you get a static map and all the information in one single page. The lat/lon links open in Yahoo Maps and you can see the location there.

If you have JavaScript enabled the interface collapses and the map is Ajax and will be refreshed every time you click on a lat/lon link.

The source code of the GeoPlanet Explorer is available on GitHub and it can give you a few pointers how to use the GeoPlanet API with YQL for your own solutions.