sending wms request to geoserver via brutile/sharpmap to load tiled map (tiled=true)

1.5k Views Asked by At

I want to load tiled map in a mapbox of SharpMap. I have GeoServer and send WMS request to that but I receive only single tile map. how can I receive multi-tile map? here is my code:

    Dim wmsUrl As String = "http://192.168.21.202:8080/geoserver/threem/gwc/service/wms?tiled=true&version=1.1.0"
    Dim layWms As New SharpMap.Layers.WmsLayer("threem_zoom", wmsUrl)
    layWms.AddLayer("threem_zoom")
    layWms.SetImageFormat("image/png")
    layWms.TimeOut = 5000
    layWms.SRID = 4326
    layWms.Version = "1.1.0"
    MapBox1.Map.Layers.Add(layWms)
    MapBox1.PanOnClick = True
    MapBox1.Map.ZoomToExtents()
    MapBox1.Refresh()
3

There are 3 best solutions below

2
pauldendulk On BEST ANSWER

This is possible using SharpMap's TileLayerAsync. See an sample of TileLayerAsync here. You need to specify a suitable tile source.

With GeoServer's tile=true it looks you still publish it as an ordinary WMS but taking into account label placing. In this case you need to something like this here

Perhaps better is to use GeoServer to publish it as a proper tile layer using TMS, WMTS or WMS-C. In that case you need to access it through BruTile's HttpTileSource.

0
Ian Turton On

From the documentation it looks as if on simple WMS layers are supported - so you would need to handle construction of the tile bounds yourself and make multiple WMS requests to get a tiled image back.

The WMS Layer support is currently pretty basic. You will have to decipher the server capabilities yourself, and specify the nessesary layers and other properties in the resource property.

0
Ehsan Zand On

I solved this problem with this code:

Try
        form1.Mapbox1.Map.Layers.Clear()
        Dim Map As Map = New Map()
        Dim xmlDoc As New XmlDocument()
        If My.Settings.Cache Then
            xmlDoc.Load("http://" & My.Settings.ServerIP & ":" & My.Settings.ServerPort & "/" & My.Settings.ServerName & "/gwc/service/wms?SERVICE=WMS&VERSION=" & My.Settings.WMSVer & "&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true")
        Else
            xmlDoc.Load("http://" & My.Settings.ServerIP & ":" & My.Settings.ServerPort & "/" & My.Settings.ServerName & "/wms?SERVICE=WMS&VERSION=" & My.Settings.WMSVer & "&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true")
        End If
        Dim xDoc = Program.ConvertToXDocument(xmlDoc)
        Dim source As List(Of ITileSource)
        source = WmscTileSource.CreateFromWmscCapabilties((xDoc))
        Dim tileSource = source.FirstOrDefault(Function(x) x.Schema.Name = My.Settings.WorkSapce & ":" & My.Settings.LayerName)
        Dim tileLayer = New TileAsyncLayer(tileSource, My.Settings.WorkSapce & ":" & My.Settings.LayerName) With {.SRID = My.Settings.SRIDNum}
        tileLayer.OnlyRedrawWhenComplete = True
        form1.Mapbox1.Map.Layers.Add(tileLayer)
        form1.Mapbox1.PanOnClick = True
        Dim env = New Envelope(44.0509701, 25.0652748, 63.3556599, 39.796795)
        form1.Mapbox1.Map.ZoomToBox(env)
        form1.Mapbox1.Map.ZoomToExtents()
        form1.Mapbox1.Map.Center = New Coordinate(53.682362, 32.420654)
        form1.Mapbox1.Refresh()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try