Skip to content

Commit 2f1ac06

Browse files
authored
tooltipOptions + example (#295)
1 parent eda4343 commit 2f1ac06

File tree

3 files changed

+87
-3
lines changed

3 files changed

+87
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Optional properties for **msg.payload** include
8888
- **popup** : html to fill the popup if you don't want the automatic default of the properties list. Using this overrides photourl, videourl and weblink options.
8989
- **label** : displays the contents as a permanent label next to the marker, or
9090
- **tooltip** : displays the contents when you hover over the marker. (Mutually exclusive with label. Label has priority)
91+
- **tooltipOptions** : custom tooltip/label options (offset, direction, permanent, sticky, interactive, opacity, className) )
9192
- **contextmenu** : an html fragment to display on right click of marker - defaults to delete marker. You can specify `${name}` to substitute in the name of the marker. Set to `""` to disable just this instance.
9293

9394
Any other `msg.payload` properties will be added to the icon popup text box. This can be

examples/Custom Tooltip.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[
2+
{
3+
"id": "ec9da974.051b48",
4+
"type": "inject",
5+
"z": "f6f2187d.f17ca8",
6+
"name": "",
7+
"repeat": "",
8+
"crontab": "",
9+
"once": false,
10+
"topic": "",
11+
"payload": "",
12+
"payloadType": "str",
13+
"x": 1010,
14+
"y": 560,
15+
"wires": [
16+
[
17+
"f77a7ed4.f955d"
18+
]
19+
]
20+
},
21+
{
22+
"id": "f77a7ed4.f955d",
23+
"type": "function",
24+
"z": "f6f2187d.f17ca8",
25+
"name": "Car + Label",
26+
"func": "var thing = {\n name:\"Jason Isaacs\", \n lat:51, \n lon:-1.45,\n icon:\"car\",\n iconColor:\"darkred\",\n extrainfo:\"Hello to Jason Isaacs\",\n label:\"This is a custom label\",\n tooltipOptions: {\"offset\" : [-100,-100], \"permanent\" : true, \"opacity\" : 1, \"direction\" : \"top\", \"className\" : \"tooltip\"}\n};\nmsg.payload = thing;\nreturn msg;",
27+
"outputs": 1,
28+
"timeout": "",
29+
"noerr": 0,
30+
"initialize": "",
31+
"finalize": "",
32+
"libs": [],
33+
"x": 1230,
34+
"y": 560,
35+
"wires": [
36+
[
37+
"f83930ff.b21488"
38+
]
39+
]
40+
},
41+
{
42+
"id": "cd09f7be.079518",
43+
"type": "comment",
44+
"z": "f6f2187d.f17ca8",
45+
"name": "Simple map - click inject to send info to map.",
46+
"info": "Adds a map at http://(your-server-ip):1880/worldmap. \n\nThe `function` node creates an object with some basic properties required to add to a map.",
47+
"x": 1170,
48+
"y": 500,
49+
"wires": []
50+
},
51+
{
52+
"id": "f83930ff.b21488",
53+
"type": "worldmap",
54+
"z": "f6f2187d.f17ca8",
55+
"name": "",
56+
"lat": "",
57+
"lon": "",
58+
"zoom": "",
59+
"layer": "OSMG",
60+
"cluster": "",
61+
"maxage": "",
62+
"usermenu": "show",
63+
"layers": "show",
64+
"panit": "false",
65+
"panlock": "false",
66+
"zoomlock": "false",
67+
"hiderightclick": "false",
68+
"coords": "none",
69+
"showgrid": "false",
70+
"showruler": "true",
71+
"allowFileDrop": "false",
72+
"path": "/worldmap",
73+
"overlist": "DR,CO,RA,DN,HM",
74+
"maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriO,EsriDG,NatGeo,UKOS,OpTop",
75+
"mapname": "",
76+
"mapurl": "",
77+
"mapopt": "",
78+
"mapwms": false,
79+
"x": 1400,
80+
"y": 560,
81+
"wires": []
82+
}
83+
]

worldmap/worldmap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,18 +2289,18 @@ function setMarker(data) {
22892289
// If .label then use that rather than name tooltip
22902290
if (data.label) {
22912291
if (typeof data.label === "boolean" && data.label === true) {
2292-
marker.bindTooltip(data["name"], { permanent:true, direction:"right", offset:labelOffset });
2292+
marker.bindTooltip(data["name"], data.tooltipOptions || { permanent:true, direction:"right", offset:labelOffset });
22932293
}
22942294
else if (typeof data.label === "string" && data.label.length > 0) {
2295-
marker.bindTooltip(data.label, { permanent:true, direction:"right", offset:labelOffset });
2295+
marker.bindTooltip(data.label, data.tooltipOptions || { permanent:true, direction:"right", offset:labelOffset });
22962296
}
22972297
delete marker.options.title;
22982298
delete data.label;
22992299
}
23002300
// otherwise check for .tooltip then use that rather than name tooltip
23012301
else if (data.tooltip) {
23022302
if (typeof data.tooltip === "string" && data.tooltip.length > 0) {
2303-
marker.bindTooltip(data.tooltip, { direction:"bottom", offset:[0,4] });
2303+
marker.bindTooltip(data.tooltip, data.tooltipOptions || { direction:"bottom", offset:[0,4] });
23042304
delete marker.options.title;
23052305
delete data.tooltip;
23062306
}

0 commit comments

Comments
 (0)