Book Image

OpenLayers 3.x Cookbook - Second Edition

By : Peter J. Langley, Antonio Santiago Perez
Book Image

OpenLayers 3.x Cookbook - Second Edition

By: Peter J. Langley, Antonio Santiago Perez

Overview of this book

OpenLayers 3 is one of the most important and complete open source JavaScript mapping libraries today. Throughout this book, you will go through recipes that expose various features of OpenLayers 3, allowing you to gain an insight into building complex GIS web applications. You will get to grips with the basics of creating a map with common functionality and quickly advance to more complicated solutions that address modern challenges. You will explore into maps, raster and vector layers, and styling in depth. This book also includes problem solving and how-to recipes for the most common and important tasks.
Table of Contents (14 chapters)
OpenLayers 3.x Cookbook Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Drawing in freehand mode


We showed you how to draw features back in Chapter 5, Adding Controls in the Drawing features across multiple vector layers recipe. OpenLayers also offers a freehand mechanism to draw features on vector layers using the ol.interaction.Draw class. Freehand mode can be defined as sketching something over the map without the defined accuracy and direction that you get when drawing a geometry type without freehand mode.

Having the flexibility to draw with more freedom can be useful in many application requirements. For example, it may be less arduous to create a path along a road with the continuous drawing flow of freehand, rather than having to click to add a point each time on the road as you go. With freehand mode, points are automatically added for you as you move the mouse in the direction that you want to draw in.

OpenLayers supports the freehand drawing of either polygons or lines. In this recipe, we're going to explore drawing polygons in freehand mode. After...