Hello all,
It seems that the very act of creating LayerDrawingOptions is causing some issues that I can't figure out.
If DL.LayerDrawingOptions Is Nothing Then
DL.LayerDrawingOptions = New LayerDrawingOptionsCollection
For Each l As LayerInfo In DL.Layers
DL.LayerDrawingOptions.Add(New LayerDrawingOptions With {.ShowLabels = True, .Opacity = 1, .LayerID = l.ID})
Next
End IfFirst, it forces a legend refresh (and looks "bad" as a result). OK, so then I sort of resolved that by not adding the layer to the legend until after the code above runs. However, the second issue is that layers that are not on by default in the published MapService are turned on. That is, if the MapService is published with layers :
"layers": [ |
| { |
| "id": 0, |
| "name": "Geoprobe Locations", |
| "parentLayerId": -1, |
| "defaultVisibility": false, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 1, |
| "name": "Bubble Locations", |
| "parentLayerId": -1, |
| "defaultVisibility": false, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 2, |
| "name": "Wells", |
| "parentLayerId": -1, |
| "defaultVisibility": false, |
| "subLayerIds": [ |
| 3, |
| 4, |
| 5 |
| ], |
| "minScale": 0, |
| "maxScale": 0 |
| }, |
| { |
| "id": 3, |
| "name": "Oil and Gas Wells", |
| "parentLayerId": 2, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 4, |
| "name": "Injection Wells", |
| "parentLayerId": 2, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 5, |
| "name": "Water Wells", |
| "parentLayerId": 2, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 6, |
| "name": "Whitestar Pipelines", |
| "parentLayerId": -1, |
| "defaultVisibility": false, |
| "subLayerIds": null, |
| "minScale": 577792, |
| "maxScale": 0 |
| }, |
| { |
| "id": 7, |
| "name": "Sinkhole", |
| "parentLayerId": -1, |
| "defaultVisibility": true, |
| "subLayerIds": [ |
| 8, |
| 9 |
| ], |
| "minScale": 0, |
| "maxScale": 0 |
| }, |
| { |
| "id": 8, |
| "name": "Sinkhole Outline", |
| "parentLayerId": 7, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 72225, |
| "maxScale": 0 |
| }, |
| { |
| "id": 9, |
| "name": "Sinkhole", |
| "parentLayerId": 7, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 72225 |
| }, |
| { |
| "id": 10, |
| "name": "Coastal Permits", |
| "parentLayerId": -1, |
| "defaultVisibility": false, |
| "subLayerIds": [ |
| 11, |
| 12 |
| ], |
| "minScale": 0, |
| "maxScale": 0 |
| }, |
| { |
| "id": 11, |
| "name": "Coastal_Permit_Lines", |
| "parentLayerId": 10, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 288896, |
| "maxScale": 0 |
| }, |
| { |
| "id": 12, |
| "name": "Coastal_Permit_Polygons", |
| "parentLayerId": 10, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 288896, |
| "maxScale": 0 |
| }, |
| { |
| "id": 13, |
| "name": "Salt Dome", |
| "parentLayerId": -1, |
| "defaultVisibility": true, |
| "subLayerIds": [ |
| 14, |
| 15 |
| ], |
| "minScale": 0, |
| "maxScale": 0 |
| }, |
| { |
| "id": 14, |
| "name": "Salt Dome Outline", |
| "parentLayerId": 13, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 15, |
| "name": "Salt Dome", |
| "parentLayerId": 13, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 144449, |
| "maxScale": 0 |
| }, |
| { |
| "id": 16, |
| "name": "Louisiana Public Land Survey", |
| "parentLayerId": -1, |
| "defaultVisibility": true, |
| "subLayerIds": [ |
| 17, |
| 18 |
| ], |
| "minScale": 1155582, |
| "maxScale": 0 |
| }, |
| { |
| "id": 17, |
| "name": "Township and Ranges", |
| "parentLayerId": 16, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 1155582, |
| "maxScale": 0 |
| }, |
| { |
| "id": 18, |
| "name": "Sections", |
| "parentLayerId": 16, |
| "defaultVisibility": true, |
| "subLayerIds": null, |
| "minScale": 288896, |
| "maxScale": 0 |
| } |
| ] |
After the code at the top is executed, the body of the POST the subsequently retrieves the MapServices' exported image is show below:
[{"id":3,"source":{"type":"mapLayer","mapLayerId":3},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":4,"source":{"type":"mapLayer","mapLayerId":4},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":5,"source":{"type":"mapLayer","mapLayerId":5},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":7,"source":{"type":"mapLayer","mapLayerId":7},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":8,"source":{"type":"mapLayer","mapLayerId":8},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":11,"source":{"type":"mapLayer","mapLayerId":11},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":12,"source":{"type":"mapLayer","mapLayerId":12},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":13,"source":{"type":"mapLayer","mapLayerId":13},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":14,"source":{"type":"mapLayer","mapLayerId":14},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":15,"source":{"type":"mapLayer","mapLayerId":15},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":16,"source":{"type":"mapLayer","mapLayerId":16},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":17,"source":{"type":"mapLayer","mapLayerId":17},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}},{"id":18,"source":{"type":"mapLayer","mapLayerId":18},"drawingInfo":{"transparency":0,"scaleSymbols":false,"showLabels":true}}]
This seems to turn on layers that are defined as visibile by default, but that are children of grouplayers that are defined as NOT visible by default. For example, Layers 11 and 12 are then visible despite their parent (layer 10) not being visible. It is also odd that the transparency is "0" when I've set it to 1 in the code at the top.