O'Reilly logo

Mastering OpenLayers 3 by Gábor Farkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required