Mapstraction adds support for OpenLayers

OpenLayers MapstractionMapstraction, the mapping abstraction library (write once, use any map provider) recently added increased support for OpenLayers, the very powerful, open-source Javascript mapping library. With this support Mapstraction users can now easily use the open-source OpenLayers API that is free from potentially restricting terms of service, or even use in offline and intranet applications.

You can see a demo of OpenLayers here or grab the latest revision here (r163 as of this posting).

This effort was headed up by Henri Bergius (aka Bergie), of Midgard fame, and now Mapstraction-OpenLayers will be supported in the Midgard CMS. Read more on Bergie's blog.

In addition, by default the Mapstraction-OpenLayers creation uses the OpenStreetMap tiles, therefore no longer requiring a Google Maps API key just to use OSM in Mapstraction.

Why wrap one wrapper in another?

At conferences and get togethers, the devs and users of Mapstraction and OpenLayers frequently ask the question "What's the difference between Mapstraction and OpenLayers?"

The primary distinction between the libraries is a difference in objective. Mapstraction seeks to provide a simple wrapper to meet the primary needs of a mapping user. The purpose being to make it easy for a user to read a single API and then easily switch to any of the major providers. By contrast, OpenLayers provides a very powerful, but potentially complex, interface that allows for bringing in content from OGC services, data feeds, overlays, and tile servers.

With Mapstraction generally targeting the 'lowest-common denominator' of all the API's there isn't built-in support for the additional capabilities of OpenLayers for layers, drawing, and services. However, Mapstraction goes provide a simple mechanism for gaining access to the underlying mapping provider such that a developer can utilize Mapstraction for the 80% of their development, and then access the remaining 20% provider specific capabilities directly.

All you need to do is call getMap() on the Mapstraction object to get the underlying OpenLayers object and go to town.

With this new support, it now brings Mapstraction up to 9 supported map interfaces (Yahoo, Google, Microsoft, Map24, MultiMap, MapQuest, FreeEarth, OpenLayers, OpenStreetMap). If you are a map provider and would like to find out how to be the 10th provider feel free to email the dev team -

About this article

written on
posted in TechnologyMapstraction Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.