Time for Action – adding some interactivity
In this example, we'll be using the cluster strategy, selectFeature control, and showing photo information on selection. As we go along, feel free to tweak the examples yourself, change the functionality, or anything else—that's the best way to learn!
Make a copy (or direct edit) of the code from the previous example. We'll be improving it.
We'll keep
extractAttributes
andextractStyles
. Even though we specifyextractStyles
, we're going to be using a customstyleMap
object. We're doing this so that we can still access the thumbnail image location (which is set asexternalGraphic
in the feature'sstyle
object when usingextractStyles
). Make sure theformat
object looks like the following:... format: new OpenLayers.Format.KML({ extractAttributes: true, extractStyles: true }) …
Let's add a
cluster
strategy to the vector layer now so our points cluster. Ourstrategies
array should now look like the following:strategies: [new OpenLayers...