Hi,
My solution needs to be able to generate a PDF with the map image, which is composed by a WmsOverlay and one or more LayerOverlay. I'm using the PdfSharp extension for this.
My code for the LayerOverlay part works, but I'm having difficulties on drawing the WmsOverlay layer onto the GeoCanvas using a similar setup.
I'm getting the error: Data on root level is invalid. Line 1, position 1.
Here's how the code looks:
For Each ovl As Overlay In Map1.CustomOverlays
'(checking if overlay should be output ...)
If TypeOf ovl Is WmsOverlay Then
Dim wmsovl = CType(ovl, WmsOverlay)
Dim wmslyr = New WmsRasterLayer(wmsovl.ServerUris(0))
wmslyr.Name = wmsovl.Name
For Each x In wmsovl.Parameters
wmslyr.Parameters.Add(x.Key, x.Value)
If x.Key.ToUpper = "LAYERS" Then 'necessary?
For Each lyrnam In x.Value.Split(",")
wmslyr.ActiveLayerNames.Add(lyrnam)
Next
End If
Next
'This errs !
wmslyr.Open()
wmslyr.Draw(pdfGeoCanvas, LabelsInLayer)
wmslyr.Close()
End If
If TypeOf ovl Is LayerOverlay Then
Dim layovl As LayerOverlay = ovl
For Each lyr As Layer In layovl.Layers
If lyr.IsVisible Then
'This works
lyr.Open()
lyr.Draw(pdfGeoCanvas, LabelsInLayer)
lyr.Close()
End If
Next 'lyr
End If
Next 'ovl
What am I missing ?
TIA