[OpenLayers-Dev] #736 (external graphic as style for vector points)

Andreas Hocevar andreas.hocevar at gmail.com
Thu May 31 17:08:42 EDT 2007


Hi,

I have been thinking about how to implement an aspect of OGC Styled
Layer Descriptors with OpenLayers vector renderers: using an external
graphic as style for a point.

I came up with a quite simple solution, for which I created a patch
and an extended vector-features.html example. For now, I only
implemented it for the SVG renderer, where PNG, JPEG and SVG files can
be used as external graphic.

The patch is at http://trac.openlayers.org/ticket/736

How it works:
The setStyle method of the renderer checks for a style property
"externalGraphic", which contains an URI to a bitmap. If this property
is set, the original "circle" node is removed from the root node, and
a new "image" node with the same properties and the required
attributes is created.

As in the SLD specification, only a size for the bitmap can be
specified. So external graphics will always be rendered with same
width and height. For width and height, the existing pointRadius
property is used.

I would appreciate your comments, and I will gladly implement it for
VML, too. But I would like to know if the way I did it is the way to
go, or if there are proposals for a different way.

Regards,
Andreas Hocevar.



More information about the Dev mailing list