Book Image

OpenLayers 3: Beginner's Guide

By : Thomas Gratier, Paul Spencer, Erik Hazzard
Book Image

OpenLayers 3: Beginner's Guide

By: Thomas Gratier, Paul Spencer, Erik Hazzard

Overview of this book

<p>This book is a practical, hands-on guide that provides you with all the information you need to get started with mapping using the OpenLayers 3 library.</p> <p>The book starts off by showing you how to create a simple map. Through the course of the book, we will review each component needed to make a map in OpenLayers 3, and you will end up with a full-fledged web map application. You will learn the key role of each OpenLayers 3 component in making a map, and important mapping principles such as projections and layers. You will create your own data files and connect to backend servers for mapping. A key part of this book will also be dedicated to building a mapping application for mobile devices and its specific components.</p>
Table of Contents (22 chapters)
OpenLayers 3 Beginner's Guide
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding interactions and their architecture


Until now, we never inspected relations between interactions. So, it's time to examine ol.interaction.* classes. All the classes inherit from ol.interaction.Interaction, but compared to controls, it's less simple; you also have subclasses.

See the following diagram to grasp the relationships between the different interaction classes:

An inspection of the above schema shows that every ol.interaction component inherits from ol.interaction.Interaction. In some cases, when an interaction uses a mouse, pen, or touchscreen, it will need to inherit from ol.interaction.Pointer, which deals with this use case.

You can also note with the schema that interactions are tied to touch events for mobile, mouse events like click or drag, mouse events with the mouse wheel, and the keyboard. You can combine them depending on the expected behaviors. Luckily, by default, you can deal with them with ease. Let's see how. After this, we will explore different ways...