# To add and remove a user defined button,as?

**URL:** <https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982>\
**Category:** General\
**Tags:** node-red-contrib-web-worldmap\
**Created:** [6 June 2023 06:13 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982 "2023-06-06T06:13:31Z")\
**Posts on this page:** 6\
**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:** [6 June 2023 06:13 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/1 "2023-06-06T06:13:31Z")

</div>

In the help document for node-red-contrib-web-worldmap 2.37.4, in its section: "Controlling the map" and following all the options it offers, I see that some do not work, or I don't know how to apply them very well in my " Function Node". Now I'm checking:"To add and remove a user defined button", and I just copied the example; which is this:"msg.payload.command = { "button": { "name":"My Fancy Button", "icon": "fa-star", "position":"bottomright" } };" , saying that it will add a button in the upper right corner of the map. When applying it, it does not appear.  
I don't have much knowledge in JSON but little by little I get things. I am currently making a map with LoRa sensor locations and I am exploiting all available resources.  
Thank you all for your attention and help.

---

<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:** [6 June 2023 08:10 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/2 "2023-06-06T08:10:10Z")

</div>

Here is that example as a flow

```auto
[{"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":540,"y":280,"wires":[]},{"id":"514483be921ae289","type":"inject","z":"abdd6f69c1e320b7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":150,"y":280,"wires":[["23d995c352e9cba1"]]},{"id":"23d995c352e9cba1","type":"function","z":"abdd6f69c1e320b7","name":"function 1","func":"\nmsg.payload = {};\nmsg.payload.command = { \n button: { \n name: \"My Fancy Button\", \n icon: \"fa-star\", \n position: \"bottomright\" \n } \n };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":280,"wires":[["59a42f2604899c31","b20dee3570ed95ee"]]}]

```

Note it places the button bottom right... (not upper right)

---

<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:** [6 June 2023 11:44 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/3 "2023-06-06T11:44:40Z")

</div>

Thank you very much "dceejay" for your help. I don't want to abuse, but I have the following problem: when I copy your example and paste it into a libreoffice(writer) document and then import it into a new Node-red flow; This one in its debugger answers me: "Error: Input not a JSON Array". The truth is that I don't know how to develop it better, maybe I have to break it down in the document, could it be like that?  
If you could explain it to me, I would be very grateful.  
Jaime

---

<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:** [6 June 2023 12:19 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/4 "2023-06-06T12:19:56Z")

</div>

I suspect that when you cut paste it into libreoffice it is changing the quotes slightly. Can you paste direct into node-red. ? Or use notepad etc

---

<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:** [6 June 2023 18:02 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/5 "2023-06-06T18:02:04Z")

</div>

Hi "dceejay", yes you are right, I have copied and pasted directly into the insert JSON window and it has created the nodes and the button on the map.  
Thank you so much.

---

<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:** [5 August 2023 18:02 UTC](https://discourse.nodered.org/t/to-add-and-remove-a-user-defined-button-as/78982/6 "2023-08-05T18:02:56Z")

</div>

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