O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

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 – 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.

  1. 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.
  2. 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 
                    })
    ...
  3. Now open the page and you should see thumbnails of the images:

What Just Happened?

Using

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