Add support to the vector layer to visualize point geometries with images. This

support was added, tested, and documented by Andreas Hocevar, and I want to
thank him for the work he put into this patch. It looks pretty great. (This
is from ticket #736.)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@3729 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-07-13 13:31:40 +00:00
parent 4f70df0029
commit 8e1eb78c26
4 changed files with 221 additions and 6 deletions

View File

@@ -183,7 +183,42 @@ OpenLayers.Renderer.SVG.prototype =
options = options || node._options;
if (node._geometryClass == "OpenLayers.Geometry.Point") {
node.setAttributeNS(null, "r", style.pointRadius);
if (style.externalGraphic) {
// remove old node
var id = node.getAttributeNS(null, "id");
var x = node.getAttributeNS(null, "cx");
var y = node.getAttributeNS(null, "cy");
var _featureId = node._featureId;
var _geometryClass = node._geometryClass;
var _style = node._style;
this.root.removeChild(node);
// create new image node
var node = this.createNode("image", id);
node._featureId = _featureId;
node._geometryClass = _geometryClass;
node._style = _style;
this.root.appendChild(node);
// now style the new node
if (style.graphicWidth && style.graphicHeight) {
node.setAttributeNS(null, "preserveAspectRatio", "none");
}
var width = style.graphicWidth || style.graphicHeight;
var height = style.graphicHeight || style.graphicWidth;
width = width ? width : style.pointRadius*2;
height = height ? height : style.pointRadius*2;
node.setAttributeNS(null, "x", x-(.5*width).toFixed());
node.setAttributeNS(null, "y", -y-(.5*height).toFixed());
node.setAttributeNS(null, "width", width);
node.setAttributeNS(null, "height", height);
node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic);
node.setAttributeNS(null, "transform", "scale(1,-1)");
node.setAttributeNS(null, "style", "opacity: "+style.fillOpacity);
} else {
node.setAttributeNS(null, "r", style.pointRadius);
}
}
if (options.isFilled) {