I am trying to change the color of GeoJSON LineString and put it into a separate layer using the worldmap node.
For some reason I can't make this work - see below. What am I doing wrong?
{
"payload": {
"type": "LineString",
"color": "#0000ff",
"layer": "layer1",
"coordinates": [[10, 11],[20, 21]]
}
}
Surround the colour value in quotes
Thank you for the tip - I still get default dark red color. Any other ideas?
Actually, I thought you were talking about a line. I have no idea what linestring is? Its not mentioned in the read me.
Thank you Steve for looking into this. LineString is a GeoJSON type. GeoJSON is supported in worldmap per the readme and it also claims that I can change color etc. , but I can't make it work .....
the geojson object needs to be a property within the payload. Also there is no default way of styling geojson within the spec so again we apply that from the level outside the geojson. For example
{
"name": "Myline",
"color": "#0000ff",
"layer": "layer1",
"geojson": {
"type": "LineString",
"coordinates": [
[
10,
11
],
[
20,
21
]
]
}
}
Thank you for the input - it makes perfect sense and does change the color of the LineString now. The layer is also generated and I can check/uncheck it in worldmap. However it appears that the LineString is not part of that "layer1" because the LineString stays visible even when I uncheck "layer1". Am I missing something?
Hmmmm needs more work I think.
ok - let me know how I can help...
If you could find me an extra couple of hours a day - that would be great
version 2.3.9 should now hopefully be a lot better behaved with geojson "layers"
Thank you for staying on top of this!
I'll keep a look out for version 2.3.9 - just updated to version 2.3.8 a min. ago....
Just updated to version 2.3.10 and it works great! Thank you very much.
@dceejay
I stumbled on this geojson styling issue too. Didn't think to read this forum first however. I expected the geojson to respect the defacto Mapbox SimpleStyle spec
https://help.github.com/en/github/managing-files-in-a-repository/mapping-geojson-files-on-github#styling-features
I want to fill a polygon area but it always gives me a black outline and a black opacity fill. It never respects "color" or any of the "properties" object styling.
[Edit : I found a technique - below]
I get my polygon area from a USGS water basin API (from an http request node)
https://labs.waterdata.usgs.gov/api/nldi/linked-data/nwissite/USGS-01391000/basin
then a Function node which contains:
var geo = { "type":"Feature",
"geometry":msg.payload.features[0].geometry,
"properties": {
"style":{ "stroke":"blue",
"stroke-width": 5,
"fill":"#0000FF",
"fill-opacity": 0.4,
}
}
};
var m = {name:"water basin",overlay:"water basin", geojson:geo, fit:true};
msg.payload = {command:{map:m,lat:41.02, lon:-74.17}};
return msg;
version 2.3.13 now on npm should better comply with those rules (that are not formally part of the spec... so no expectations or guarantees...
Their simplestyle example now renders correctly
[{"id":"46d5de0d.caeeb","type":"worldmap","z":"a3c2a16b.fa113","name":"","lat":"0","lon":"0","zoom":"6","layer":"","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/worldmap","x":480,"y":60,"wires":[]},{"id":"1aed2e0.d6106d2","type":"inject","z":"a3c2a16b.fa113","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":110,"y":60,"wires":[["ec7a10cc.d687e"]]},{"id":"ec7a10cc.d687e","type":"function","z":"a3c2a16b.fa113","name":"","func":"msg.payload = {\n \"type\": \"FeatureCollection\",\n \"features\": [{ \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [0, 0]\n },\n \"properties\": {\n \"marker-size\": \"medium\",\n \"marker-symbol\": \"bus\",\n \"marker-color\": \"#ace\"\n }\n }, {\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"LineString\",\n \"coordinates\": [[0, 0], [10, 10]]\n },\n \"properties\": {\n \"stroke\": \"#f000f0\",\n \"stroke-width\": 4\n }\n }]\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":60,"wires":[["46d5de0d.caeeb"]]}]
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.