Don't flip SVG Y values anymore, since we're working in pixel space these days,
and the Y transforms just make working with the SVG directly -- for example, with people modifying it to support text -- more difficult than it should be. git-svn-id: http://svn.openlayers.org/trunk/openlayers@5430 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -215,11 +215,10 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
var opacity = style.graphicOpacity || style.fillOpacity;
|
||||
|
||||
node.setAttributeNS(null, "x", (x + xOffset).toFixed());
|
||||
node.setAttributeNS(null, "y", (-y + yOffset).toFixed());
|
||||
node.setAttributeNS(null, "y", (y + yOffset).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: "+opacity);
|
||||
} else {
|
||||
node.setAttributeNS(null, "r", style.pointRadius);
|
||||
@@ -304,13 +303,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
*/
|
||||
createRoot: function() {
|
||||
var id = this.container.id + "_root";
|
||||
|
||||
var root = this.nodeFactory(id, "g");
|
||||
|
||||
// flip the SVG display Y axis upside down so it
|
||||
// matches the display Y axis of the map
|
||||
root.setAttributeNS(null, "transform", "scale(1, -1)");
|
||||
|
||||
return root;
|
||||
},
|
||||
|
||||
@@ -344,7 +337,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
drawCircle: function(node, geometry, radius) {
|
||||
var resolution = this.getResolution();
|
||||
var x = (geometry.x / resolution + this.left);
|
||||
var y = (geometry.y / resolution - this.top);
|
||||
var y = (this.top - geometry.y / resolution);
|
||||
|
||||
if (this.inValidRange(x, y)) {
|
||||
node.setAttributeNS(null, "cx", x);
|
||||
@@ -423,7 +416,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
drawRectangle: function(node, geometry) {
|
||||
var resolution = this.getResolution();
|
||||
var x = (geometry.x / resolution + this.left);
|
||||
var y = (geometry.y / resolution - this.top);
|
||||
var y = (this.top - geometry.y / resolution);
|
||||
|
||||
if (this.inValidRange(x, y)) {
|
||||
node.setAttributeNS(null, "x", x);
|
||||
@@ -504,7 +497,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
getShortString: function(point) {
|
||||
var resolution = this.getResolution();
|
||||
var x = (point.x / resolution + this.left);
|
||||
var y = (point.y / resolution - this.top);
|
||||
var y = (this.top - point.y / resolution);
|
||||
|
||||
if (this.inValidRange(x, y)) {
|
||||
return x + "," + y;
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
r.drawCircle(node, geometry, 3);
|
||||
|
||||
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, 'cy'), '-4', "cy is correct");
|
||||
t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct");
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
r.drawRectangle(node, geometry);
|
||||
|
||||
t.eq(node.getAttributeNS(null, "x"), "2", "x attribute is correctly set");
|
||||
t.eq(node.getAttributeNS(null, "y"), "4", "y attribute is correctly set");
|
||||
t.eq(node.getAttributeNS(null, "y"), "-4", "y attribute is correctly set");
|
||||
t.eq(node.getAttributeNS(null, "width"), "6", "width attribute is correctly set");
|
||||
t.eq(node.getAttributeNS(null, "height"), "8", "height attribute is correctly set");
|
||||
}
|
||||
@@ -355,7 +355,7 @@
|
||||
};
|
||||
|
||||
var string = r.getShortString(point);
|
||||
t.eq(string, "2,4", "returned string is correct");
|
||||
t.eq(string, "2,-4", "returned string is correct");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user