Suport for tooltips on externalGraphics using the graphicTitle
symbolizer property. Only supported in IE and FF. Patch by zspitzer, modified by me (added some docs, moved code that sets the title tag so it gets executed for externalGraphics. p=zspitzer, r=me (closes #1946) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9097 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -62,6 +62,8 @@
|
|||||||
style_mark.graphicXOffset = -(style_mark.graphicWidth/2); // this is the default value
|
style_mark.graphicXOffset = -(style_mark.graphicWidth/2); // this is the default value
|
||||||
style_mark.graphicYOffset = -style_mark.graphicHeight;
|
style_mark.graphicYOffset = -style_mark.graphicHeight;
|
||||||
style_mark.externalGraphic = "../img/marker.png";
|
style_mark.externalGraphic = "../img/marker.png";
|
||||||
|
// graphicTitle only works in Firefox and Internet Explorer
|
||||||
|
style_mark.graphicTitle = "this is a test tooltip";
|
||||||
|
|
||||||
var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {style: layer_style});
|
var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {style: layer_style});
|
||||||
|
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
|||||||
* graphicZIndex - {Number} The integer z-index value to use in rendering.
|
* 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),
|
* graphicName - {String} Named graphic to use when rendering points. Supported values include "circle" (default),
|
||||||
* "square", "star", "x", "cross", "triangle".
|
* "square", "star", "x", "cross", "triangle".
|
||||||
|
* graphicTitle - {String} Tooltip for an external graphic. Only supported in Firefox and Internet Explorer.
|
||||||
* backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.
|
* 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.
|
* 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.
|
* backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
|||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = style.externalGraphic;
|
img.src = style.externalGraphic;
|
||||||
|
|
||||||
|
if(style.graphicTitle) {
|
||||||
|
img.title=style.graphicTitle;
|
||||||
|
}
|
||||||
|
|
||||||
var width = style.graphicWidth || style.graphicHeight;
|
var width = style.graphicWidth || style.graphicHeight;
|
||||||
var height = style.graphicHeight || style.graphicWidth;
|
var height = style.graphicHeight || style.graphicWidth;
|
||||||
width = width ? width : style.pointRadius*2;
|
width = width ? width : style.pointRadius*2;
|
||||||
|
|||||||
@@ -250,6 +250,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
if (style.externalGraphic) {
|
if (style.externalGraphic) {
|
||||||
pos = this.getPosition(node);
|
pos = this.getPosition(node);
|
||||||
|
|
||||||
|
if (style.graphicTitle) {
|
||||||
|
node.setAttributeNS(null, "title", style.graphicTitle);
|
||||||
|
}
|
||||||
if (style.graphicWidth && style.graphicHeight) {
|
if (style.graphicWidth && style.graphicHeight) {
|
||||||
node.setAttributeNS(null, "preserveAspectRatio", "none");
|
node.setAttributeNS(null, "preserveAspectRatio", "none");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,9 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
if (node._geometryClass == "OpenLayers.Geometry.Point") {
|
if (node._geometryClass == "OpenLayers.Geometry.Point") {
|
||||||
if (style.externalGraphic) {
|
if (style.externalGraphic) {
|
||||||
this.drawGraphic(node, geometry, style);
|
this.drawGraphic(node, geometry, style);
|
||||||
|
if (style.graphicTitle) {
|
||||||
|
node.title=style.graphicTitle;
|
||||||
|
}
|
||||||
// modify style/options for fill and stroke styling below
|
// modify style/options for fill and stroke styling below
|
||||||
style.fillColor = "none";
|
style.fillColor = "none";
|
||||||
options.isStroked = false;
|
options.isStroked = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user