fixed aspect ratio rendering in IE to not break rotation any more.
r=pgiraud (closes #1836) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9217 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -198,24 +198,38 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
|
|
||||||
if (node._geometryClass == "OpenLayers.Geometry.Point") {
|
if (node._geometryClass == "OpenLayers.Geometry.Point") {
|
||||||
if (style.externalGraphic) {
|
if (style.externalGraphic) {
|
||||||
this.drawGraphic(node, geometry, style);
|
|
||||||
if (style.graphicTitle) {
|
if (style.graphicTitle) {
|
||||||
node.title=style.graphicTitle;
|
node.title=style.graphicTitle;
|
||||||
}
|
}
|
||||||
|
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";
|
||||||
|
|
||||||
// modify style/options for fill and stroke styling below
|
// modify style/options for fill and stroke styling below
|
||||||
style.fillColor = "none";
|
style.fillColor = "none";
|
||||||
options.isStroked = false;
|
options.isStroked = false;
|
||||||
} else if (this.isComplexSymbol(style.graphicName)) {
|
} else if (this.isComplexSymbol(style.graphicName)) {
|
||||||
var cache = this.importSymbol(style.graphicName);
|
var cache = this.importSymbol(style.graphicName);
|
||||||
var symbolExtent = cache.extent;
|
|
||||||
var width = symbolExtent.getWidth();
|
|
||||||
var height = symbolExtent.getHeight();
|
|
||||||
node.setAttribute("path", cache.path);
|
node.setAttribute("path", cache.path);
|
||||||
node.setAttribute("coordorigin", symbolExtent.left + "," +
|
node.setAttribute("coordorigin", cache.left + "," +
|
||||||
symbolExtent.bottom);
|
cache.bottom);
|
||||||
node.setAttribute("coordsize", width + "," + height);
|
var size = cache.size;
|
||||||
var ratio = width / height;
|
node.setAttribute("coordsize", size + "," + size);
|
||||||
this.drawGraphic(node, geometry, style, ratio);
|
this.drawCircle(node, geometry, style.pointRadius);
|
||||||
|
node.style.flip = "y";
|
||||||
} else {
|
} else {
|
||||||
this.drawCircle(node, geometry, style.pointRadius);
|
this.drawCircle(node, geometry, style.pointRadius);
|
||||||
}
|
}
|
||||||
@@ -626,33 +640,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
return false;
|
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
|
* Method: drawLineString
|
||||||
* Render a linestring.
|
* Render a linestring.
|
||||||
@@ -875,10 +863,21 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
}
|
}
|
||||||
pathitems.push("x e");
|
pathitems.push("x e");
|
||||||
var path = pathitems.join(" ");
|
var path = pathitems.join(" ");
|
||||||
|
|
||||||
|
var diff = (symbolExtent.getWidth() - symbolExtent.getHeight()) / 2;
|
||||||
|
if(diff > 0) {
|
||||||
|
symbolExtent.bottom = symbolExtent.bottom - diff;
|
||||||
|
symbolExtent.top = symbolExtent.top + diff;
|
||||||
|
} else {
|
||||||
|
symbolExtent.left = symbolExtent.left - diff;
|
||||||
|
symbolExtent.right = symbolExtent.right + diff;
|
||||||
|
}
|
||||||
|
|
||||||
cache = {
|
cache = {
|
||||||
path: path,
|
path: path,
|
||||||
extent: symbolExtent
|
size: symbolExtent.getWidth(), // equals getHeight() now
|
||||||
|
left: symbolExtent.left,
|
||||||
|
bottom: symbolExtent.bottom
|
||||||
};
|
};
|
||||||
this.symbolCache[id] = cache;
|
this.symbolCache[id] = cache;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user