Thursday, March 13, 2014

Book Review: OpenLayers Cookbook

I recently got my hands on a copy of the OpenLayers Cookbook by Antonio Santiago Perez published by Packt Publishing.


The baseline of the book is "60 recipes to create GIS web applications with the open source JavaScript library". This means that the book is based on 60 examples which can be viewed online . The code is also available on github.
I like this style: the way I search for specific OpenLayers features is usually by studying example programs such as the ones on the OpenLayers website. It gives a quick feel of whether a certain feature is feasible or not and how much work it would take to implement.
There is always a danger with this type of approach and that is that you start copy/pasting code which you don't understand. This is where this book shows it's advantage over the examples on the OpenLayers website: apart from the code, which is well readable and formatted, every example is accompanied by a section "how it works" and usually also links to related examples. Every chapter also starts with an introduction which covers the basic classes and concepts used.

The book contains content for both beginners  and advanced users. I skipped quickly through the first three chapters: Web mapping basics, adding raster layers and working with vector layers. I should add that topics are discussed in detail: clustering of vector features, filtering of WFS requests.

A GIS application often is only as good as it looks, and two chapters discuss the theming of the openlayers interface and the styling of map features. The examples go all the way down to creating a new custom theme.

As a more advanced OpenLayers users I liked these chapters and the three remaining ( working with events, adding controls, beyond the basics) the most. Some non-obvious extensions to openlayers are discussed: interacting with services, creating custom controls and renderers, ...
Almost evrery application of OpenLayers can benefit from some of the recipes in these chapters.

Conclusion

I can recommend this book to anyone who wants to build applications with OpenLayers. The structure with recipes allows one to quickly find out how a feature can be implemented, moreover there is always a complete explanation of of how things work in the book (and where things can go wrong, such as cross domain requests).

If I have to talk about one disadvantage of the book? Development of OpenLayers 3 (which is incompatible with OpenLayers 2) is ongoing and beta 2 has been released recently. Since this book is from 2012 it predates most of these recent developments. I would have loved a chapter highlighting what best-practices one should follow to make a switch to a future version of OpenLayers as easy as possible.