SVG renderer draws features in the upperleft corner of the map pane when coordinate outside range. r=tschaub (closes #1360)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6380 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-02-27 00:47:55 +00:00
parent 99265c2581
commit 9c55f8c1e1
2 changed files with 10 additions and 8 deletions

View File

@@ -192,9 +192,11 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
setStyle: function(node, style, options) {
style = style || node._style;
options = options || node._options;
if (node._geometryClass == "OpenLayers.Geometry.Point") {
var x = node.getAttributeNS(null, "cx");
// if x equals "", the node is outside the valid range
if (node._geometryClass == "OpenLayers.Geometry.Point" && x) {
if (style.externalGraphic) {
var x = parseFloat(node.getAttributeNS(null, "cx"));
x = parseFloat(x);
var y = parseFloat(node.getAttributeNS(null, "cy"));
if (style.graphicWidth && style.graphicHeight) {
@@ -337,9 +339,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
node.setAttributeNS(null, "cy", y);
node.setAttributeNS(null, "r", radius);
} else {
if (node.parentNode == this.root) {
this.root.removeChild(node);
}
node.setAttributeNS(null, "cx", "");
node.setAttributeNS(null, "cy", "");
node.setAttributeNS(null, "r", 0);
}
},

View File

@@ -155,9 +155,9 @@
r.drawCircle(node, geometry, "blah_4000");
t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct");
t.eq(node.getAttributeNS(null, 'cy'), '-4', "cy is correct");
t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct");
t.eq(node.getAttributeNS(null, 'cx'), '', "cx is correct");
t.eq(node.getAttributeNS(null, 'cy'), '', "cy is correct");
t.eq(node.getAttributeNS(null, 'r'), '0', "r is correct");
}
function test_SVG_drawlinestring(t) {