Creating new interactions

Creating new interactions is a little different than creating new controls. Instead of using a single root class, we can use ol.interaction.Pointer and ol.interaction.Interaction. We will cover, in this chapter, why we should use the pointer class. In this example, called ch05_pointer, we will implement two custom interactions. One for removing features and one for dragging features. Firstly, we define some CSS rules for our new controls, as usual:

.toolbar .ol-removefeat button {
    background-image: url(../../res/button_removefeat.png);
}
.toolbar .ol-dragfeat button {
    background-image: url(../../res/button_dragfeat.png);
}

Understanding ol.interaction.Pointer

Before creating some custom interaction, let's discuss how the ...

Get Mastering OpenLayers 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.