Preserve aspect ratio for custom symbols in the vml renderer. Original

patch by fredj, refactored by me, r=pgiraud. (closes #1836)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9026 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2009-03-12 13:19:06 +00:00
parent e89774d568
commit d2c0182fd9
2 changed files with 35 additions and 25 deletions

View File

@@ -198,23 +198,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
if (node._geometryClass == "OpenLayers.Geometry.Point") {
if (style.externalGraphic) {
var width = style.graphicWidth || style.graphicHeight;
var height = style.graphicHeight || style.graphicWidth;
width = width ? width : style.pointRadius*2;
height = height ? height : style.pointRadius*2;
var resolution = this.getResolution();
var xOffset = (style.graphicXOffset != undefined) ?
style.graphicXOffset : -(0.5 * width);
var yOffset = (style.graphicYOffset != undefined) ?
style.graphicYOffset : -(0.5 * height);
node.style.left = ((geometry.x/resolution - this.offset.x)+xOffset).toFixed();
node.style.top = ((geometry.y/resolution - this.offset.y)-(yOffset+height)).toFixed();
node.style.width = width + "px";
node.style.height = height + "px";
node.style.flip = "y";
this.drawGraphic(node, geometry, style);
// modify style/options for fill and stroke styling below
style.fillColor = "none";
options.isStroked = false;
@@ -227,13 +211,8 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
node.setAttribute("coordorigin", symbolExtent.left + "," +
symbolExtent.bottom);
node.setAttribute("coordsize", width + "," + height);
node.style.left = symbolExtent.left + "px";
node.style.top = symbolExtent.bottom + "px";
node.style.width = width + "px";
node.style.height = height + "px";
this.drawCircle(node, geometry, style.pointRadius);
node.style.flip = "y";
var ratio = width / height;
this.drawGraphic(node, geometry, style, ratio);
} else {
this.drawCircle(node, geometry, style.pointRadius);
}
@@ -644,7 +623,33 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
return false;
},
/**
* Method: drawGraphic
*
* Parameters:
* node - {DOMElement}
* geometry - {<OpenLayers.Geometry>}
* style - {Object}
* ratio - {Number}
*/
drawGraphic: function(node, geometry, style, ratio) {
var diameter = style.pointRadius * 2;
var width = style.graphicWidth || diameter;
var height = style.graphicHeight || (ratio ? diameter / ratio : diameter);
var resolution = this.getResolution();
var xOffset = (style.graphicXOffset != undefined) ?
style.graphicXOffset : -(0.5 * width);
var yOffset = (style.graphicYOffset != undefined) ?
style.graphicYOffset : -(0.5 * height);
node.style.left = ((geometry.x/resolution - this.offset.x)+xOffset).toFixed();
node.style.top = ((geometry.y/resolution - this.offset.y)-(yOffset+height)).toFixed();
node.style.width = width + "px";
node.style.height = height + "px";
node.style.flip = "y";
},
/**
* Method: drawLineString
* Render a linestring.