[OpenLayers-Users] custom feature markers

Christopher Schmidt crschmidt at metacarta.com
Tue Jan 27 07:21:56 EST 2009


On Tue, Jan 27, 2009 at 02:18:10PM +0200, Samuli Saarinen wrote:
> Hello,
> 
> I'm creating an application which uses OL to show objects on a map. I'm 
> using OL to load KML file from the server using vector layer with BBOX 
> strategy and HTTP protocol.
> 
> It all works fine but there is one problem. I should be able to draw 
> markers for the features dynamically based on some values on the kml 
> data. I have tried to find an example that does this but so far I 
> haven't been able to find one. All the examples I have found use the 
> style framework with either the graphicName to show predifined symbols 
> or externalGraphic to show custom static images.

http://docs.openlayers.org/library/feature_styling

"In this way, the style can contain rendering information which is
dependant on the feature: for example, in a Style object, the string
${thumbnail} is replaced by the feature’s ‘thumbnail’
attribute."

However, OpenLayers KML support does not have support for any kind of
attribute parsing from KML other than title and description. I would
recommend that you should instead use KML <Style> or <StyleURL> blocks,
and set extractStyles to true on your KML format, which will indicate
that OpenLayers should parse and use those styles. 

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list