The next step is to display some information about photos when they are selected. To do this, we'll need to listen for an event on the select interaction's collection of selected features and retrieve the features that were selected. Our plan is to have some photo information display when we select features:
Let's go ahead and get the framework for this set up first, by simply creating a
<div>
tag that will appear below the map. In your HTML code, add the following line after the map's<div>
tag:<div id='photo_info ></div>
The select interaction doesn't provide events directly related to features being selected or deselected, but it does maintain a collection of selected events and the collection object has events for adding and removing items. First, get a reference to the selected features:
var selectedFeatures = select.getFeatures();
Now, we can listen for the
add
event. For now, let's put the URL of the selected photo into...