There is no reason to restrict graphicTitle to externalGraphic symbols.

This commit is contained in:
ahocevar
2012-05-05 12:49:25 +02:00
parent b61cfdb054
commit d01f57d3e6
3 changed files with 20 additions and 18 deletions

View File

@@ -239,6 +239,21 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
setStyle: function(node, style, options) {
style = style || node._style;
options = options || node._options;
if (style.graphicTitle) {
node.setAttributeNS(null, "title", style.graphicTitle);
//Standards-conformant SVG
// Prevent duplicate nodes. See issue https://github.com/openlayers/openlayers/issues/92
var titleNode = node.getElementsByTagName("title");
if (titleNode.length > 0) {
titleNode[0].firstChild.textContent = style.graphicTitle;
} else {
var label = this.nodeFactory(null, "title");
label.textContent = style.graphicTitle;
node.appendChild(label);
}
}
var r = parseFloat(node.getAttributeNS(null, "r"));
var widthFactor = 1;
var pos;
@@ -248,20 +263,6 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
node.style.visibility = "hidden";
} else if (style.externalGraphic) {
pos = this.getPosition(node);
if (style.graphicTitle) {
node.setAttributeNS(null, "title", style.graphicTitle);
//Standards-conformant SVG
// Prevent duplicate nodes. See issue https://github.com/openlayers/openlayers/issues/92
var titleNode = node.getElementsByTagName("title");
if (titleNode.length > 0) {
titleNode[0].firstChild.textContent = style.graphicTitle;
} else {
var label = this.nodeFactory(null, "title");
label.textContent = style.graphicTitle;
node.appendChild(label);
}
}
if (style.graphicWidth && style.graphicHeight) {
node.setAttributeNS(null, "preserveAspectRatio", "none");
}