Skip to content

Commit

Permalink
There is no reason to restrict graphicTitle to externalGraphic symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed May 5, 2012
1 parent b61cfdb commit d01f57d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/OpenLayers/Feature/Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
* graphicZIndex - {Number} The integer z-index value to use in rendering.
* graphicName - {String} Named graphic to use when rendering points. Supported values include "circle" (default),
* "square", "star", "x", "cross", "triangle".
* graphicTitle - {String} Tooltip for an external graphic.
* graphicTitle - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.
* backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.
* backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.
* backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.
Expand Down
29 changes: 15 additions & 14 deletions lib/OpenLayers/Renderer/SVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand Down
7 changes: 4 additions & 3 deletions lib/OpenLayers/Renderer/VML.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
options = options || node._options;
var fillColor = style.fillColor;

if (style.graphicTitle) {
node.title=style.graphicTitle;
}

if (node._geometryClass === "OpenLayers.Geometry.Point") {
if (style.externalGraphic) {
options.isFilled = true;
if (style.graphicTitle) {
node.title=style.graphicTitle;
}
var width = style.graphicWidth || style.graphicHeight;
var height = style.graphicHeight || style.graphicWidth;
width = width ? width : style.pointRadius*2;
Expand Down

0 comments on commit d01f57d

Please sign in to comment.