Skip to main content

Blogs: Advanced Mapping with Open Layers

Google Maps is great. We've been building Google Maps solutions for clients for a few years now with some great results:

The Drupal gmap module makes building these types of maps relatively quick, simple and painless, however as people want to do more and more with mapping there are some limitations with this approach:

  1. Single Data Layer You can only display one layer of data on a map. Views and it's filters can be used to control the data queried in Drupal and displayed on the map, however combining various content types on a map with more complex rules around their display quickly starts to reach the limitations of what's possible.
  2. Minimal customisations available You can easily tweak the pins or markers displayed on the map, however you are restricted to using the 3 main base layers provided, Map, Satellite and Terrain views.
  3. Charges for high usage Google introduced charges for high usage of their Maps API in January 2012. Users who regularly make more than 25,000 hits per day will need to start paying for hits above that limit.  Other mapping providers are offering free or cheaper services that provide more value by allowing more customisations and support for multiple layers. Recently foursquare switched to using Open Street Map and MapBox to provide their mapping layer over Google Maps.

What are base/data layers? What about tiles?

A base layer is the graphical display of the map and is made up tiles, different tiles are loaded depending on the provider/zoom level. These tiles are provided by mapping hosts.

The data layer is the pins or markers that are plotted on the map, this data typically lives within the site and is managed via the CMS.

What can we do with Open Layers?

Open Layers is an open source mapping engine that integrates with most the leading map tile providers. Open layers also supports multiple data layers, allowing us to easily layer up data on a map with different search or query criteria for each layer.

Let's talk though an example:

Custom Base Layers

This map features a custom base layer called "Geography Class" provided by MapBox. Open Layers allows us to expose the tools to switch base layers to site users, allowing them to choose the layer that works best for them. This layer can come from a number of providers including MapBox, Cloudmade, OpenStreeMap and more.

CloudMade and MapBox allow you to build completely custom baselayers with your own colour schemes, iconography and lots more customisations.

Overlays

Our example has 4 overlays which can be toggled on and off. Each one of these relates to a different view in Drupal - our simple example divides the content by a location type taxonomy but any combination of views filters can be used to split the data across layers. For example these could be ranges in price of properties, star ratings for restaurants or types or content within the CMS.

Conclusion

Open Layers provides an advanced and flexible mapping implementation and is fast growing traction as the mapping solution to use. Combined with custom base layers provided by map designing services such as CloudMade, its easy to create engaging maps that match the design of a site and maximise usability.

We'll be looking to implement OpenLayers over straight Google Maps on new projects unless there's a compelling reasons not to.

Try out the above example

Next up: Open Layers support for Mobile and Vectors

Comments

Add new comment