Time for Action – extract style
The extractStyles
can be used to style the vector layer based on the styles specified in the KML file. Because the Flickr KML file provides style information, we can use this property—let's see how.
If the KML file you are working with contains style information, we can directly access and use it. In this case, Flickr is providing us with a KML file embedded with style tags, so let's use it.
We'll specify
extractStyles: true
inside our vector layer creation call. In the format value setting, add it in, and be sure to include the comma:... format: new OpenLayers.Format.KML({ extractAttributes: true, extractStyles: true }) ...
Now open the page and you should see thumbnails of the images:
What Just Happened?
Using extractStyles
, our features went from the default orange dots to thumbnails of the actual uploaded photos. When this property is used, style definitions in the KML file are applied to the
style...