O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

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

Time for action – adding the select interaction

So, let's go ahead and add a select interaction to our application:

  1. To add feature selection ability, create a select interaction. We'll add events soon, but for now, let's just create the control and add it to the map and then activate it. Add this at the end of the main <script> tag after all the other code:
    var select = new ol.interaction.Select({
      layers: [flickrLayer]
    });
    map.addInteraction(select);
  2. If you try this out, you'll see that when you click on a feature or a cluster, it turns into a blue dot with a white stroke around it. This is the default style for selected point features, and isn't really what we want. A simple thing for us to do is to make the photo larger when it is selected. 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