So, let's go ahead and add a select interaction to our application:
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);
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 select interaction has a
style
option that allows us to do this. We'll create a new function to return a selected style by making a copy of ourflickrStyle
function and cache object, using a larger scale value, and using the new style function...