1

I have geoserver and sharpmap and when I add one layer as tiled map it works perfect but when I want to add a group layer which contains several layers it shows nothing. this is my code:

        Mapbox1.Map.Layers.Clear()
    Dim Map As Map = New Map()
    Dim xmlDoc As New XmlDocument()
    xmlDoc.Load("http://192.168.21.29:8080/geoserver/finalCH/wms?SERVICE=WMS&VERSION=1.1.0&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true&srs=EPSG:4326&layer=finalCH:GroupLayer")
    Dim xDoc = Program.ConvertToXDocument(xmlDoc)
    Dim source As List(Of ITileSource)
    source = WmscTileSource.CreateFromWmscCapabilties((xDoc))
    Dim tileSource = source.FirstOrDefault(Function(x) x.Schema.Name = "GroupLayer")
    Dim TileLayer = New TileAsyncLayer(tileSource, "GroupLayer") With {.SRID = 4326}
    TileLayer.OnlyRedrawWhenComplete = True
    Mapbox1.Map.Layers.Add(TileLayer)
    Mapbox1.PanOnClick = True
    Mapbox1.Map.ZoomToExtents()
    Mapbox1.Refresh()

any suggestion?

Edit: Above code works for a single layer fine, but in geoserver I have several layers which added to a group layer, "GroupLayer". scale dependency is implemented in SLD files at Geoserver. The group is in finalCH workspace. As I know in sharpmap for tiled maps, you should download getcapabilities XML file and sharpmap will do the job with it. I have no problem to show the GroupLayer as single tile. my code for a single tile layer is different. I'm using SharpMap.WMSLayer for that:

Try
        Mapbox1.Map.Layers.Clear()
        Dim wmsUrl As String = "http://192.168.21.29:8080/geoserver/finalCH/gwc/service/wms?version=1.1.0" 
        'Adding Layers and Set Layers Properties
        Dim layWms As New WmsLayer("GroupLayer", wmsUrl)
        layWms.AddLayer("GroupLayer")
        layWms.SetImageFormat("image/png")
        layWms.ContinueOnError = True
        layWms.TimeOut = 50000
        'set projection format
        layWms.SRID = 4326
        'force wms version
        layWms.Version = "1.1.0"
        'add layer to map
        Mapbox1.Map.Layers.Add(layWms)
        Mapbox1.PanOnClick = True
        'set center of map to center of map box
        Dim env = New Envelope(44.0509701, 25.0652748, 63.3556599, 39.796795)
        Mapbox1.Map.ZoomToExtents()
        Mapbox1.Refresh()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
  • does it work for a single layer from the group? is there any scale dependency set on the layers? is there anything shown in the GeoServer log file? are you sure the groups is in the finalCH workspace? are you sure you want to request the capabilities and not a map? – Ian Turton Nov 16 '16 at 13:22
  • does the code above work for a single layer? – Ian Turton Nov 16 '16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.