Fixes and performance improvements to VML renderer problems with
externalGraphic, diligently filed, investigated, and fixed by The great and powerful Oz, er, Andreas, who is becoming my new vector rendering hero. (Closes #1172) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5323 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -105,19 +105,20 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
|
||||
/**
|
||||
* Method: getNodeType
|
||||
* Get the noode type for a geometry
|
||||
* Get the noode type for a geometry and style
|
||||
*
|
||||
* Parameters:
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
* style - {Object}
|
||||
*
|
||||
* Returns:
|
||||
* {String} The corresponding node type for the specified geometry
|
||||
*/
|
||||
getNodeType: function(geometry) {
|
||||
getNodeType: function(geometry, style) {
|
||||
var nodeType = null;
|
||||
switch (geometry.CLASS_NAME) {
|
||||
case "OpenLayers.Geometry.Point":
|
||||
nodeType = "v:oval";
|
||||
nodeType = style.externalGraphic ? "v:rect" : "v:oval";
|
||||
break;
|
||||
case "OpenLayers.Geometry.Rectangle":
|
||||
nodeType = "v:rect";
|
||||
@@ -153,29 +154,6 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
|
||||
if (node._geometryClass == "OpenLayers.Geometry.Point") {
|
||||
if (style.externalGraphic) {
|
||||
// remove old node
|
||||
var id = node.id;
|
||||
var _featureId = node._featureId;
|
||||
var _geometryClass = node._geometryClass;
|
||||
var _style = node._style;
|
||||
|
||||
// create new image node
|
||||
node = this.createNode("v:rect", id);
|
||||
var fill = this.createNode("v:fill", id+"_image");
|
||||
node.appendChild(fill);
|
||||
node._featureId = _featureId;
|
||||
node._geometryClass = _geometryClass;
|
||||
node._style = _style;
|
||||
|
||||
fill.src = style.externalGraphic;
|
||||
fill.type = "frame";
|
||||
node.style.flip = "y";
|
||||
|
||||
if (!(style.graphicWidth && style.graphicHeight)) {
|
||||
fill.aspect = "atmost";
|
||||
}
|
||||
|
||||
// now style the new node
|
||||
var width = style.graphicWidth || style.graphicHeight;
|
||||
var height = style.graphicHeight || style.graphicWidth;
|
||||
width = width ? width : style.pointRadius*2;
|
||||
@@ -192,9 +170,9 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
node.style.width = width;
|
||||
node.style.height = height;
|
||||
|
||||
// modify fill style for rect styling below
|
||||
// modify style/options for fill and stroke styling below
|
||||
style.fillColor = "none";
|
||||
style.strokeColor = "none";
|
||||
options.isStroked = false;
|
||||
|
||||
} else {
|
||||
this.drawCircle(node, geometry, style.pointRadius);
|
||||
@@ -216,16 +194,29 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
} else {
|
||||
if (!fill) {
|
||||
fill = this.createNode('v:fill', node.id + "_fill");
|
||||
|
||||
if (style.fillOpacity) {
|
||||
fill.setAttribute("opacity", style.fillOpacity);
|
||||
}
|
||||
|
||||
if (node._geometryClass == "OpenLayers.Geometry.Point" &&
|
||||
style.externalGraphic) {
|
||||
|
||||
// override fillOpacity
|
||||
if (style.graphicOpacity) {
|
||||
fill.setAttribute("opacity", style.graphicOpacity);
|
||||
}
|
||||
|
||||
fill.setAttribute("src", style.externalGraphic);
|
||||
fill.setAttribute("type", "frame");
|
||||
node.style.flip = "y";
|
||||
|
||||
if (!(style.graphicWidth && style.graphicHeight)) {
|
||||
fill.aspect = "atmost";
|
||||
}
|
||||
}
|
||||
node.appendChild(fill);
|
||||
}
|
||||
// if graphicOpacity is set use it in priority for external graphic
|
||||
if (node._geometryClass == "OpenLayers.Geometry.Point" &&
|
||||
style.externalGraphic &&
|
||||
style.graphicOpacity) {
|
||||
fill.setAttribute("opacity", style.graphicOpacity);
|
||||
} else if (style.fillOpacity) {
|
||||
fill.setAttribute("opacity", style.fillOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,6 +248,29 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
return node;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: postDraw
|
||||
* Some versions of Internet Explorer seem to be unable to set fillcolor
|
||||
* and strokecolor to "none" correctly before the fill node is appended to
|
||||
* a visible vml node. This method takes care of that and sets fillcolor
|
||||
* and strokecolor again if needed.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
*/
|
||||
postDraw: function(node) {
|
||||
var fillColor = node._style.fillColor;
|
||||
var strokeColor = node._style.strokeColor;
|
||||
if (fillColor == "none" &&
|
||||
node.getAttribute("fillcolor") != fillColor) {
|
||||
node.setAttribute("fillcolor", fillColor);
|
||||
}
|
||||
if (strokeColor == "none" &&
|
||||
node.getAttribute("strokecolor") != strokeColor) {
|
||||
node.setAttribute("strokecolor", strokeColor)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: setNodeDimension
|
||||
|
||||
Reference in New Issue
Block a user