Change color of existing polygon on node-red-contrib-web-worldmap

I have created a map with a layer and one polygon with id=1.I want to have two buttons one to chnage the color of the polygon to red and one to blue, but i don't want to remove the layer to add again with new color. Is it possible to access the polygon element to change the color?

[
    {
        "id": "67d7c975fbac3b40",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "d4ab8d40.31c81",
        "type": "function",
        "z": "67d7c975fbac3b40",
        "name": "",
        "func": "var building={\n  \"type\": \"FeatureCollection\",\n  \"features\": [\n    {\n      \"type\": \"Feature\",\n      \"properties\": {},\n      \"geometry\": {\n        \"coordinates\": [\n          [\n            [\n              -8.419921058015802,\n              41.833635881442035\n            ],\n            [\n              -8.419857581949827,\n              41.83362750200473\n            ],\n            [\n              -8.419843586685602,\n              41.833684831708524\n            ],\n            [\n              -8.419906866415005,\n              41.833692809150506\n            ],\n            [\n              -8.419921058015802,\n              41.833635881442035\n            ]\n          ]\n        ],\n        \"type\": \"Polygon\"\n      },\n      \"id\": 1\n    \n    }\n  ]\n};\nmsg.payload=building;\n\nvar m = {overlay:msg.topic, geojson:msg.payload, fit:true};\n\nmsg.payload = {command:{map:m, lat:41.83361, lon:-8.41993,zoom:20,rotation:-80}};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 300,
        "wires": [
            [
                "f64e5234.4402e"
            ]
        ]
    },
    {
        "id": "f64e5234.4402e",
        "type": "worldmap",
        "z": "67d7c975fbac3b40",
        "name": "",
        "lat": "",
        "lon": "",
        "zoom": "",
        "layer": "OSMC",
        "cluster": "",
        "maxage": "",
        "usermenu": "show",
        "layers": "show",
        "panit": "false",
        "panlock": "false",
        "zoomlock": "false",
        "hiderightclick": "false",
        "coords": "none",
        "showgrid": "false",
        "allowFileDrop": "false",
        "path": "/worldmap",
        "overlist": "DR,CO,DN",
        "maplist": "OSMG,OSMC,EsriC,EsriS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 880,
        "y": 300,
        "wires": []
    },
    {
        "id": "62ae3b3c.8de704",
        "type": "worldmap in",
        "z": "67d7c975fbac3b40",
        "name": "",
        "path": "/worldmap",
        "events": "connect",
        "x": 320,
        "y": 300,
        "wires": [
            [
                "d4ab8d40.31c81"
            ]
        ]
    },
    {
        "id": "7d93819391f856f1",
        "type": "inject",
        "z": "67d7c975fbac3b40",
        "name": "CHANGE POLYGON ID=1 TO BLUE",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 420,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "088c615d260576de",
        "type": "inject",
        "z": "67d7c975fbac3b40",
        "name": "CHANGE POLYGON ID=1 TO RED",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 420,
        "y": 460,
        "wires": [
            []
        ]
    }
]

On phone so can’t look at code but you should just be able to rewrite the object with the new colour. As long as the name is the same it will just update.

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