Add msg.tooltip, and update readme

This commit is contained in:
Dave Conway-Jones 2019-03-10 14:23:53 +00:00
parent a30a4859b7
commit 2de1b0bec5
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 20 additions and 5 deletions

View File

@ -64,7 +64,8 @@ Optional properties include
- **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on the heatmap layer. (default 1.0)
- **popped** : set to true to automatically open the popup info box, set to false to close it.
- **popup** : html to fill the popup if you don't want the automatic default of the properties list.
- **label** : displays the contents of label next to the icon.
- **label** : displays the contents as a permanent label next to the marker, or
- **tooltip** : displays the contents when you hover over the marker. (Mutually exclusive with label. Label has priority)
Any other `msg.payload` properties will be added to the icon popup text box. This can be overridden
by using the **popup** property to supply your own html content.
@ -244,6 +245,10 @@ The **worldmap in** node can be used to receive various events from the map. Exa
{ "action": "button", "name": "My Fancy Button" } // when a user defined button is clicked
{ "action": "feedback", "name": "some name", "value": "some value" } // when a user calls the feedback function - see below
There is a function available to make sending date to Node-RED easier (e.g. from inside a user defined popup), called feedback() - it takes two parameters, name and value, and can be used inside something like an input tag - `onchange='feedback(this.name,this.value)'`. Value can be a more complex object if required as long as it is serialisable.
All actions also include a `msg._sessionid` property that indicates which client session they came from. Any msg sent out that include this will ONLY to that session - so you can target map updates to certain sessions only if required.
## Controlling the map

View File

@ -114,7 +114,8 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<li><code>icon</code> : <a href="https://fontawesome.com/v4.7.0/icons/" target="_new">font awesome</a> icon name or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>, or url of icon image.</li>
<li><code>iconColor</code> : standard CSS color name or #rrggbb hex value.</li>
<li><code>SIDC</code> : NATO symbology code (instead of icon).</li>
<li><code>label</code> : permanent label next to icon.</li>
<li><code>label</code> : permanent label next to marker, or</li>
<li><code>tooltip</code> : hover over text for marker. (alternative to label)</li>
<li><code>bulding</code> : OSMBuildings GeoJSON object.</li>
<li><code>ttl</code> : time to live of an individual marker before deletion.</li>
<li><code>photoUrl</code> : adds an image pointed at by the url to the popup box.</li>
@ -122,7 +123,7 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<li><code>weblink</code> : link to an external web page.</li>
<li><code>deleted</code> : set to <i>true</i> to remove the named marker. (default false)</li>
</ul>
<p>Any other sub-properties of <code>msg.payload</code> will be added to the icon popup text box as extra information.</p>
<p>Any other sub-properties of <code>msg.payload</code> will be added to the marker popup text box as extra information.</p>
<p>Icons of type <i>plane</i>, <i>ship</i>, <i>car</i>, <i>uav</i> or <i>arrow</i> will use built in SVG icons that align to the
<code>bearing</code> value.</p>
<p>Font Awesome (<a href="https://fontawesome.com/v4.7.0/icons/" target="_new">fa-icons 4.7</a>) can also be used, as can
@ -214,6 +215,7 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<li><b>layer</b> - when a base layer is changed</li>
<li><b>addlayer</b> - when an overlay is added to the map</li>
<li><b>dellayer</b> - when an overlay is removed from the map</li>
<li><b>feedback</b> - when a user calls the feedback() function in the browser</li>
</ul>
Use the debug node to see the complete payload of the msg returned.</p>
<p>All actions also include a <code>msg._sessionid</code> property that indicates which client session the

View File

@ -1333,6 +1333,14 @@ function setMarker(data) {
delete marker.options.title;
delete data.label;
}
// otherwise check for .tooltip then use that rather than name tooltip
else if (data.tooltip) {
if (typeof data.tooltip === "string" && data.tooltip.length > 0) {
marker.bindLabel(data.tooltip, { direction:"left", offset:[22,-16] });
delete marker.options.title;
delete data.tooltip;
}
}
// Add any remaining properties to the info box
var llc = data.lineColor;
@ -1357,7 +1365,7 @@ function setMarker(data) {
marker._popup.dname = data.name;
marker.lay = lay; // and the layer it is on
var rightmenuMarker = L.popup().setContent("<b>"+data.name+"</b><br/><button id='delbutton' onclick='delMarker(\""+data.name+"\",true);'>Delete</button>");
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data.name+"</b><br/><button id='delbutton' onclick='delMarker(\""+data.name+"\",true);'>Delete</button>");
marker.on('contextmenu', function(e) {
if (hiderightclick !== true) {
rightmenuMarker.setLatLng(e.latlng);

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Mar 2nd 2019 - v1.5.29a
# date: Mar 2nd 2019 - v1.5.29b
CACHE:
index.html