fixed rotation center for non-square symbols in non-defs mode (Webkit). r=bartvde (closes #2499)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10136 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -41,10 +41,12 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
translationParameters: null,
|
translationParameters: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: symbolSize
|
* Property: symbolMetrics
|
||||||
* {Object} Cache for symbol sizes according to their svg coordinate space
|
* {Object} Cache for symbol metrics according to their svg coordinate
|
||||||
|
* space. This is an object keyed by the symbol's id, and values are
|
||||||
|
* an array of [width, centerX, centerY].
|
||||||
*/
|
*/
|
||||||
symbolSize: {},
|
symbolMetrics: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: isGecko
|
* Property: isGecko
|
||||||
@@ -75,6 +77,8 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
this.translationParameters = {x: 0, y: 0};
|
this.translationParameters = {x: 0, y: 0};
|
||||||
this.supportUse = (navigator.userAgent.toLowerCase().indexOf("applewebkit/5") == -1);
|
this.supportUse = (navigator.userAgent.toLowerCase().indexOf("applewebkit/5") == -1);
|
||||||
this.isGecko = (navigator.userAgent.toLowerCase().indexOf("gecko/") != -1);
|
this.isGecko = (navigator.userAgent.toLowerCase().indexOf("gecko/") != -1);
|
||||||
|
|
||||||
|
this.symbolMetrics = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +302,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
var size = offset * 2;
|
var size = offset * 2;
|
||||||
var id = this.importSymbol(style.graphicName);
|
var id = this.importSymbol(style.graphicName);
|
||||||
pos = this.getPosition(node);
|
pos = this.getPosition(node);
|
||||||
widthFactor = this.symbolSize[id] / size;
|
widthFactor = this.symbolMetrics[id][0] * 3 / size;
|
||||||
|
|
||||||
// remove the node from the dom before we modify it. This
|
// remove the node from the dom before we modify it. This
|
||||||
// prevents various rendering issues in Safari and FF
|
// prevents various rendering issues in Safari and FF
|
||||||
@@ -344,10 +348,10 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
"rotate(" + rotation + " " + pos.x + " " +
|
"rotate(" + rotation + " " + pos.x + " " +
|
||||||
pos.y + ")");
|
pos.y + ")");
|
||||||
} else {
|
} else {
|
||||||
var symbolCenter = 0.5 * this.symbolSize[id] / 3;
|
var metrics = this.symbolMetrics[id]
|
||||||
node.firstChild.setAttributeNS(null, "transform",
|
node.firstChild.setAttributeNS(null, "transform",
|
||||||
"rotate(" + rotation + " " + symbolCenter +
|
"rotate(" + style.rotation + " " + metrics[1] +
|
||||||
" " + symbolCenter + ")");
|
" " + metrics[2] + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -932,7 +936,11 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
var viewBox = [symbolExtent.left - width,
|
var viewBox = [symbolExtent.left - width,
|
||||||
symbolExtent.bottom - height, width * 3, height * 3];
|
symbolExtent.bottom - height, width * 3, height * 3];
|
||||||
symbolNode.setAttributeNS(null, "viewBox", viewBox.join(" "));
|
symbolNode.setAttributeNS(null, "viewBox", viewBox.join(" "));
|
||||||
this.symbolSize[id] = Math.max(width, height) * 3;
|
this.symbolMetrics[id] = [
|
||||||
|
Math.max(width, height),
|
||||||
|
symbolExtent.getCenterLonLat().lon,
|
||||||
|
symbolExtent.getCenterLonLat().lat
|
||||||
|
];
|
||||||
|
|
||||||
this.defs.appendChild(symbolNode);
|
this.defs.appendChild(symbolNode);
|
||||||
return symbolNode.id;
|
return symbolNode.id;
|
||||||
|
|||||||
@@ -412,7 +412,7 @@
|
|||||||
var points = polygon.getAttribute("points");
|
var points = polygon.getAttribute("points");
|
||||||
|
|
||||||
t.eq(points.replace(/ /g,''), "0,00,11,11,00,0", "Square symbol rendered correctly");
|
t.eq(points.replace(/ /g,''), "0,00,11,11,00,0", "Square symbol rendered correctly");
|
||||||
t.ok(r.symbolSize["-square"], "Symbol size cached correctly.");
|
t.ok(r.symbolMetrics["-square"], "Symbol metrics cached correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_svg_dashstyle(t) {
|
function test_svg_dashstyle(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user