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
About the Authors
About the Reviewer

Styling interaction render intents

There are some map interactions, such as Draw and Select, which change the style of the feature depending on its current state, that is, if it is currently being drawn or selected. There are also other interactions that create temporary geometries, such as the DragZoom interaction, which draws out a rectangle over the map representing the extent that you wish to view.

This recipe shows us how we can modify the styles used for each of these render intents to change the look of our applications.

We will create a panel above the map that allows the user to enable the draw or select interactions. They will be able to perform DragZoom whenever they like. The source code can be found in ch06/ch06-styling-interaction-render-intents, and the styling for the Draw interaction render intent will look like the following screenshot:

How to do it…

Find out how to style interaction render intents by following these instructions:

  1. Create a new HTML file and add the OpenLayers...