# Create a legend on the map

**URL:** https://discourse.nodered.org/t/create-a-legend-on-the-map/78931
**Category:** General
**Tags:** node-red-contrib-web-worldmap
**Created:** [3 June 2023 18:43 UTC](https://discourse.nodered.org/t/create-a-legend-on-the-map/78931 "2023-06-03T18:43:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jaime](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jaime](https://discourse.nodered.org/u/jaime)
#### Post date: [3 June 2023 18:43 UTC](https://discourse.nodered.org/t/create-a-legend-on-the-map/78931/1 "2023-06-03T18:43:20Z")

</div>

Hello everyone, I have a problem with obtaining a legend on the map that presents the "worldmap" node. I have accessed the document: "node-red-contrib-web-worldmap 2.37.4" and in its "command" section it says to obtain the legend: "(To add and remove a legend  
If you want to add a small legend overlay

msg.payload.command = { "legend": " **Title**  
\<i style="background: #477AC2"\> Water  
\<i style=\ "background: #448D40"\>Forest  
" };  
To remove set the legend to an empty string ."")". dedicating a function node to it and applying the message, I can't see the example.  
Could someone help me? How should I compose the message? I don't know JSON very well.  
Thank you

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [4 June 2023 08:01 UTC](https://discourse.nodered.org/t/create-a-legend-on-the-map/78931/2 "2023-06-04T08:01:18Z")

</div>

Here is that example as a flow

```auto
[{"id":"580d66cc9df1f9f5","type":"inject","z":"abdd6f69c1e320b7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":130,"y":180,"wires":[["b76750ca4e7343c9"]]},{"id":"b76750ca4e7343c9","type":"function","z":"abdd6f69c1e320b7","name":"function 1","func":"msg.payload ={};\nmsg.payload.command = { \"legend\": \"<b>Title</b></br><i style=\\\"background: #477AC2\\\"></i> Water<br><i style=\\\"background: #448D40\\\"></i> Forest<br>\" };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":180,"wires":[["59a42f2604899c31"]]},{"id":"59a42f2604899c31","type":"worldmap","z":"abdd6f69c1e320b7","name":"","lat":"","lon":"","zoom":"","layer":"","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"false","showgrid":"false","showruler":"false","allowFileDrop":"false","path":"/worldmap","overlist":"DR,CO,RA,DN,HM","maplist":"OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":520,"y":180,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![jaime](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jaime](https://discourse.nodered.org/u/jaime)
#### Post date: [4 June 2023 17:08 UTC](https://discourse.nodered.org/t/create-a-legend-on-the-map/78931/3 "2023-06-04T17:08:46Z")

</div>

Hello and thank you very much for giving me a hand so soon. I see that you have described the complete FLOW to me, thank you very much.  
Jaime

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 June 2023 17:09 UTC](https://discourse.nodered.org/t/create-a-legend-on-the-map/78931/4 "2023-06-18T17:09:27Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
