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

Removing or cloning features using overlays

A common characteristic of web mapping applications is their ability to display information or perform actions that are related to the features on the map. By features, we mean any real phenomenon or aspect that we can visually represent with points, lines, polygons, and so on.

We can select a feature, retrieve its associated information, and choose to display it anywhere in our application layout. A common way to do this is using overlays.

In this recipe, we'll make it possible to clone and remove a feature from an overlay bubble that is displayed when clicking on a feature attached to the map. The source code can be found in ch03/ch03-removing-cloning-feature-overlay. This will look like the following screenshot:

How to do it…

We will perform some feature manipulation from map overlays using the following instructions:

  1. Create an HTML file with OpenLayers dependencies, a div element to hold the map, and also the overlay and content, as follows: