reverting r11645, and fixing the root of the reported problem. r=bartvde (closes #2392)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11697 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-03-11 19:28:55 +00:00
parent 807000c4b7
commit 120d59f0e1
3 changed files with 16 additions and 27 deletions
+8 -8
View File
@@ -290,9 +290,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
// the symbol viewBox is three times as large as the symbol
var offset = style.pointRadius * 3;
var size = offset * 2;
var id = this.importSymbol(style.graphicName);
var src = this.importSymbol(style.graphicName);
pos = this.getPosition(node);
widthFactor = this.symbolMetrics[id][0] * 3 / size;
widthFactor = this.symbolMetrics[src.id][0] * 3 / size;
// remove the node from the dom before we modify it. This
// prevents various rendering issues in Safari and FF
@@ -308,7 +308,6 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
// See e.g. ticket http://trac.osgeo.org/openlayers/ticket/2985
// and this email thread
// http://osgeo-org.1803224.n2.nabble.com/Select-Control-Ctrl-click-on-Feature-with-a-graphicName-opens-new-browser-window-tc5846039.html
var src = document.getElementById(id);
node.firstChild && node.removeChild(node.firstChild);
node.appendChild(src.firstChild.cloneNode(true));
node.setAttributeNS(null, "viewBox", src.getAttributeNS(null, "viewBox"));
@@ -339,7 +338,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
"rotate(" + rotation + " " + pos.x + " " +
pos.y + ")");
} else {
var metrics = this.symbolMetrics[id];
var metrics = this.symbolMetrics[src.id];
node.firstChild.setAttributeNS(null, "transform", "rotate("
+ rotation + " "
+ metrics[1] + " "
@@ -881,7 +880,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
* graphicName - {String} name of the symbol to import
*
* Returns:
* {String} - id of the imported symbol
* {DOMElement} - the imported symbol
*/
importSymbol: function (graphicName) {
if (!this.defs) {
@@ -891,8 +890,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
var id = this.container.id + "-" + graphicName;
// check if symbol already exists in the defs
if (document.getElementById(id) != null) {
return id;
var existing = document.getElementById(id)
if (existing != null) {
return existing;
}
var symbol = OpenLayers.Renderer.symbol[graphicName];
@@ -934,7 +934,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
];
this.defs.appendChild(symbolNode);
return symbolNode.id;
return symbolNode;
},
/**