The ability to measure distances or areas is an important feature for many GIS applications. For example, a user may wish to draw out a path along some roads to figure out the distance of a journey. Or you may want to draw a polygon around your neighbor's back garden to see how many acres they have!
OpenLayers 2 conveniently came with a measuring control straight out of the box. However, at the time of writing this book, OpenLayers 3 doesn't offer this convenience. However, you'll be pleased to know that this can be cobbled together with the methods that are available to us without much fuss.
The application will contain a sidebar with radio inputs in order to select a measurement type, either area or distance. The user will be able to draw anywhere on the map and see a live update of the measurement in the sidebar as they go. For mobile, the updates will be seen after every new point has been placed on the map.
The source code can be found in