Mapstraction

2nd October 2006 @ 1:58 pm
javascript, Maps, mapstraction and weblog
A while ago Steve, Mikel and I released Mapstraction, a javascript library that abstracts away the differences between the leading maps APIs (namely Google Maps, Yahoo Maps and Microsoft Virtual Earth).  We wrote it so that people embedding maps in their websites needn't be dependent on one provider, especially if (when) terms and conditions are changed, or the data on offer changes (for example Yahoo's maps of London are currently very basic, but if they improve I would prefer to use their API over Google's). 

The key thing about Mapstraction is that you can switch APIs with only one line of code.  If your business depends on Google Maps then you should already be doing this, but it also seems like a natural thing to open source.  (UK property search engine Nestoria agreed, and funded the initial development).  It's already in use in GeoPress, for embedding maps in Wordpress blog posts, and Phil recently used it to add maps to Pepys' Diary.

We hope to keep Mapstraction as a lightweight layer to make porting it to any future APIs as simple as possible.  It also offers us the chance to normalise the functionality offered by different libraries, for example we offered a polyline implementation for Yahoo Maps before the functionality officially launched, and we intend to allow a choice of geo-coders for postcode and place-name lookup rather than be tied to the geocoder of your current API provider.

It's worth noting that other people are offering similar things (and more), most notably OpenLayers which offers a complete tiled "slippy" map implementation to make using with your own (or a third-party's) WMS (Web Map Server) as easy as possible.