I spoke at the Web Directions What Do You Know night in Brisbane tonight. Here's a slightly more in-depth version of what I talked about, with links to all the good stuff. You can also view my slides though they're quite large.
Recently the Google Maps Mania blog wrote a post entitled “The slow death of the Google Maps API”, not so much lamenting the demise of Google Maps as much as embracing the change that’s occurred in this space and it got me thinking.
Google Maps used to be the only real solution to showing maps online, and I’m sure you’ve plopped down the Google Maps embed code on a contact page in your day. But lately there’s been a lot more choices cropping up in both software and services so I’m going to quickly go through some of the cool stuff you can do with maps.
Mapbox: probably better than Google?
Firstly I’ll mention that in my opinion the main competitor to the Google Maps API right now is Mapbox. Mapbox has a bunch of services and APIs for both apps and the web, and you should check them out if you haven’t already (their blog is well worth a read too).
They have a sweet web interface that lets you completely customise your map styles and content, and offer a bunch of goodies for creating and managing maps including TileMill which is the ultimate map mashup customisation whatsit.
If you’re looking to plop a map onto a contact page these guys can absolutely get you there, but if you’re looking to do a full-on data visualisation they’ve got you covered too.
Leaflet
Mapbox are throwing a lot of support behind open source tools like Mapnik, Node and especially Leaflet.js which is the BSD licensed mapping library that most of their service runs on.
Leaflet is especially nice to use as both a user and a developer because it’s it’s super-fast and works well even down to IE7. It's completely styleable with CSS has excellent touch support for mobile devices which makes it really awesome if you need a responsive maps solution.
In terms of data visualisation, it uses SVG by default (with a VML fallback) or you can draw onto HTML5 canvas if you don’t need IE8. There's also a large number of modules you can use, both official and otherwise.
Heatwave Tracker
I’ll briefly mention the ABC News heatwave tracker which I did late last year, showing an animated map of temperatures for the past week.
This one was originally going to use Google Maps but had some performance issues on mobile that prompted the move to Leaflet.
This visualisation ended up using the basic Leaflet API to draw circles for each weather station and animating them using requestAnimationFrame. Under the hood Leaflet created a SVG circle for each of these points which turned out to be hardware accelerated to varying degrees across browsers, so it was super fast with around six-hundred data points updating at sixty frames per second.
There was no particularly tricky code involved in this, it’s all just using Leaflet’s standard APIs without any optimisations on the map side of things. The Leaflet port from Google Maps took about an hour which gives you some indication as to the effort involved.
100 Years of Air Travel
The Guardian has a much more impressive interactive with their 100 Years of Aviation feature.
This feature used a combo of Leaflet with a bunch of custom code to create a collage of maps, images, and audio showing the history of air travel. The most interesting feature is the html5 canvas-based visualisation showing all the planes in the sky over the last twenty-four hours which you can zoom, pan, and explore like a traditional map.
It's kinda mesmerising.
This one was commissioned by The Guardian and built by Kiln who I have somewhat of a map geek crush on right now. They used TileMill for the background layer (I had a suspicion!).
@k_i_l_n @AshKyd In more detail, Natural Earth polygons + SRTM30 elevation data processed with gdaldem for the relief shading layers.
— Robin Houston (@robinhouston) March 23, 2014
What about D3?
But Leaflet isn’t the only client-side library that’s doing interesting things in mapping. While Leaflet is positioned as a more traditional Google Maps replacement, D3 takes a more data-driven approach to visualising geodata.
For those not aware, D3 stands for “data driven documents” and you might remember Colin Gourlay talking about using D3 for responsive charts in the last Last What Do You Know in September.
Well D3 also has geodata functionality that can do wonderful things with more of a focus on your raw data rather than a traditional map.
This demo is from the D3 geo.projection plugin shows a few of the different types of map projection you can use in your projects, and you can see the way the map is animating between different projections that the library has a lot of power over a traditional flat map.
Earth
While this isn’t something you’d usually use in itself, it does lend to some interesting ways of visualising data, such as in the Earth global weather visualisation by @cambecc.
This is a really compelling mashup of wind, air pressure and temperature projected on a 2D globe then animated to show about as close as you can get to real time world-wide weather conditions.
This demo uses D3 and Backbone.js to display data which has been pre-processed from a number of different sources. It’s using the orthographic projection of D3 which presents a sweet 2d globe effect which you can spin and zoom to explore the nuances of the planet.
Because this is using the HTML5 canvas as a 2d drawing platform, all the individual data points you see moving on the screen have to be calculated each time you adjust your viewpoint. This is all done in D3 rather than on a GPU for instance, which might not be something you'd do in a super-high performance situation, but it's a really good demo of what D3 is capable of.
Google is still good…
Google Maps is still great, but they've really been focusing more on the consumer with their offerings of late.
The new version of Google Maps is a fantastic use of WebGL and is really a showcase use for the technology, but you can't develop against it for use in your own apps. In terms of the Maps APIs they've stagnated over the years and as a result we're seeing more innovation from other players rather than Google themselves.
So next time you're looking at doing anything to do with maps, check out some of the alternatives. You might find yourself getting more done, doing cooler things and generally looking better among your peers.
What does everyone else know?
If you weren't at Web Directions What Do You Know, here are some the other talks from the night.
- Sarah Bock
- Narcissism and the web
- Andy Fitzsimon
- Generative design is awesome (My personal favourite, I want to play with netengine.io)
- Luke Brooker
- Craft as in Beer
- Jilly Magee
- Data is the real King (and yep, content is data)