Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenLayers 3.x Cookbook

You're reading from   OpenLayers 3.x Cookbook This book will provide users with a variety of recipes that illustrate different features present in OpenLayers 3

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781785287756
Length 304 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Antonio Santiago Antonio Santiago
Author Profile Icon Antonio Santiago
Antonio Santiago
Peter J. Langley Peter J. Langley
Author Profile Icon Peter J. Langley
Peter J. Langley
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Web Mapping Basics FREE CHAPTER 2. Adding Raster Layers 3. Working with Vector Layers 4. Working with Events 5. Adding Controls 6. Styling Features 7. Beyond the Basics Index

Selecting features by dragging out a selection area


One common action when working with features within a vector layer is its selection, and, of course, OpenLayers has some feature selection controls that are available to us. We've already seen this demonstrated in earlier recipes, such as the Removing or cloning features using overlays recipe in Chapter 3, Working with Vector Layers. This recipe showed us how to select one feature at a time with a click or tap gesture.

This recipe will show you how to select multiple features at once using a combination of interactions. The ol.interaction.Select class is for the render intent and grouping of selected features, and the other is ol.interaction.DragBox, which is used to enable the user to drag out a rectangle over the map. The joint effort of these two controls will produce a multiselect capability.

Once these features have been selected, we'll display the selected count and enable the user to delete the selected features from the sidebar.

The...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image