I'm working on a C# project using MapWinGIS 4.9 and Geoserver 2.13 Previously I've stored Shapefiles in Geoserver and I want to load in a C# project using MapWinGIS control.

I'm using WmsLayer Class Reference but still had no idea how should I call the GetMap request from geoserver.

Also I've been searching for documentation but had no success.

Does someone have an idea?

  • 1
    According to the documentation ~ mapwindow.org/documentation/mapwingis4.9/… you don't need to construct the GetMap request, just set the baseURL – nmtoken Jul 11 '18 at 12:06
  • It's not clear to me the way to create a WmsLayer and then add to the AxMap control. Also the reference points to the function AddLayer() but had no success. – KrVa Jul 12 '18 at 16:06
  • Property TransparentColor is type of UInt so in case of using white color as transparent it should be something like (VB.NET): Dim c As Color = Color.White Dim b() As Byte = BitConverter.GetBytes(c.ToArgb) wmsLayer.TransparentColor = BitConverter.ToUInt32(b, 0) (C#.NET): Color c = Color.White; wmsLayer.TransparentColor = (uint)(((c.A << 24) | (c.R << 16) | (c.G << 8) | c.B); – jiri Oct 4 '18 at 12:14

It was not so complicated, here is an example:

//We need a control map, a wmsLayer and a layerHandle.
AxMap axMap = new AxMap();
int layerHandle = -1;
WmsLayer wmsLayer = new WmsLayer();
Extents extents = new Extents();

//Set the wmsLayer properties, taken from geoserver.
extents.SetBounds(-180, -90, 0, 0, 90, 0);
wmsLayer.BaseUrl = "http://localhost:8080/geoserver/seceot_test/wms";
wmsLayer.BoundingBox = extents;
wmsLayer.Contrast = (float)1.0;
wmsLayer.DoCaching = false;
wmsLayer.Epsg = 4326;
wmsLayer.Format = @"image%2Fpng";
wmsLayer.Gamma = (float)1.0;
wmsLayer.Layers = "dev_test:infrastructure_100k";
wmsLayer.Name = "Infrastructure 100k";
wmsLayer.Opacity = 255;
wmsLayer.UseCache = false;
wmsLayer.Id = 1;
wmsLayer.UseTransparentColor = false;
wmsLayer.Key = "1";
wmsLayer.Version = tkWmsVersion.wvAuto;
wmsLayer.TransparentColor = 255;
wmsLayer.UseTransparentColor = true;

// If everything is correct, AddLayer() does the job.
layerHandle = axMap.AddLayer(wmsLayer, true);

// Testing purposes, should print "Layers added to the map: 1"
Console.WriteLine("Layers added to the map: {0}", this.axMap.NumLayers);

And that's all!

Your Answer

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

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