1

I produce maps using Leaflet and the Esri Leaflet plugin.

Here is a MapService layer from the USGS pertaining to the risk of debris flow. Note that if attribute combhazcl=3 then this data is colored red by the server. Yes, this service supports dynamic layers.

https://earthquake.usgs.gov/arcgis/rest/services/ls/pwfdf_2018/MapServer/6

What is the REST syntax to change the color of just the combhazcl=3 data? I do not work for the USGS and thus cannot change the default styling on the server.

Here is my call for one tile without any restyling.

https://earthquake.usgs.gov/arcgis/rest/services/ls/pwfdf_2018/MapServer/export?bboxSR=4326&layers=show:6&size=256,256&imageSR=3857&format=png&transparent=true&dpi=&f=image&bbox=-117.48779296875,33.72433966174761,-117.4658203125,33.706062655101206

And here is my call for the same tile trying to make combhazcl=3 green.

https://earthquake.usgs.gov/arcgis/rest/services/ls/pwfdf_2018/MapServer/export?bboxSR=4326&layers=show:6&size=256,256&imageSR=3857&format=png&transparent=true&dpi=&f=image&layerDefs={6:"combhazcl=3"}&dynamicLayers=[{'source':{'type':'mapLayer','mapLayerId':6},'definitionExpression':'combhazcl=3','drawingInfo':{'renderer':{'type':'simple','symbol':{'type':'esriSFS',"style":"esriSFSSolid","color":[0,0,0,0],'outline':{'type':'esriSLS','style':'esriSLSSolid','color':[0,255,0,255],'width':3}}}}}]&bbox=-117.48779296875,33.72433966174761,-117.4658203125,33.706062655101206

Yes, the above tile call did select just the data where combhazcl=3. But I am unable to restyle that data.

Can anyone shed light on where I have gone astray with the syntax?

In general I am able to restyle dynamic layer data without any trouble. But this is the first time I have tried to restyle data where the server defines different styling based on an attribute value.

1 Answer 1

3

Your link didn't work for me, but this shows green lines:

https://earthquake.usgs.gov/arcgis/rest/services/ls/pwfdf_2018/MapServer/export?dynamicLayers=[{"id":6,"name":"Segment Combined Hazard Estimates","source":{"type":"mapLayer","mapLayerId":6},"definitionExpression":"combhazcl = 3","drawingInfo":{"renderer":{"type":"uniqueValue","field1":"combhazcl","field2":null,"field3":null,"fieldDelimiter":",","defaultSymbol":null,"defaultLabel":null,"uniqueValueInfos":[{"value":"1","symbol":{"color":[255,255,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"Low"},{"value":"2","symbol":{"color":[255,170,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"Moderate"},{"value":"3","symbol":{"color":[76,230,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"High"}]}},"minScale":0,"maxScale":0}]&dpi=96&transparent=true&format=png32&layers=show:6&bbox=-13232868.053459939,4031991.7385576465,-13210548.441200696,4044546.5204534694&bboxSR=102100&imageSR=102100&size=1168,657&layerDefs={"6":"combhazcl = 3"}&f=image

I got this by making an ArcGIS online webmap (http://arcg.is/18a0fz), and editing there: enter image description here

Then change symbol:

enter image description here

Then OK, then DONE, then right click and copy export url in the Chrome Devtools. enter image description here

Then paste into https://www.urldecoder.org/ and click decode.

That gave me a decypherable url.

https://earthquake.usgs.gov/arcgis/rest/services/ls/pwfdf_2018/MapServer/export?dynamicLayers=[{"id":6,"name":"Segment Combined Hazard Estimates","source":{"type":"mapLayer","mapLayerId":6},"drawingInfo":{"renderer":{"type":"uniqueValue","field1":"combhazcl","field2":null,"field3":null,"fieldDelimiter":",","defaultSymbol":null,"defaultLabel":null,"uniqueValueInfos":[{"value":"1","symbol":{"color":[255,255,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"Low"},{"value":"2","symbol":{"color":[255,170,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"Moderate"},{"value":"3","symbol":{"color":[56,168,0,255],"width":2,"type":"esriSLS","style":"esriSLSSolid"},"label":"High"}]}},"minScale":0,"maxScale":0}]&dpi=96&transparent=true&format=png32&layers=show:6&bbox=-13230130.055220343,4034436.016786233,-13218970.249090724,4040713.407734145&bboxSR=102100&imageSR=102100&size=1168,657&f=image

The part of interest is json after the dynamicLayers, so I used https://jsonformatter.curiousconcept.com/ to format it:

[
   {
      "id":6,
      "name":"Segment Combined Hazard Estimates",
      "source":{
         "type":"mapLayer",
         "mapLayerId":6
      },
      "drawingInfo":{
         "renderer":{
            "type":"uniqueValue",
            "field1":"combhazcl",
            "field2":null,
            "field3":null,
            "fieldDelimiter":",",
            "defaultSymbol":null,
            "defaultLabel":null,
            "uniqueValueInfos":[
               {
                  "value":"1",
                  "symbol":{
                     "color":[
                        255,
                        255,
                        0,
                        255
                     ],
                     "width":2,
                     "type":"esriSLS",
                     "style":"esriSLSSolid"
                  },
                  "label":"Low"
               },
               {
                  "value":"2",
                  "symbol":{
                     "color":[
                        255,
                        170,
                        0,
                        255
                     ],
                     "width":2,
                     "type":"esriSLS",
                     "style":"esriSLSSolid"
                  },
                  "label":"Moderate"
               },
               {
                  "value":"3",
                  "symbol":{
                     "color":[
                        56,
                        168,
                        0,
                        255
                     ],
                     "width":2,
                     "type":"esriSLS",
                     "style":"esriSLSSolid"
                  },
                  "label":"High"
               }
            ]
         }
      },
      "minScale":0,
      "maxScale":0
   }
]
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.