This project has moved and is read-only. For the latest updates, please go here.

Example 3: Adding a WMS-layer to the map

It's really easy to add a WMS-layer to the SharpMap map
Add the code below to the the code you've written so far in this tutorial

SharpMap.Layers.WmsLayer wmsL = new SharpMap.Layers.WmsLayer(
    "US Cities", 
    "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer");

//Force PNG format. Else we can't see through
wmsL.SetImageFormat("image/png");
//Force version 1.1.0
wmsL.Version = "1.1.0";
//Add layer named 2 in the service (Cities)
wmsL.AddLayer("2");
//Set the SRID
wmsL.SRID = 4326;

//Add layer to map
mapBox1.Map.Layers.Add(wmsL);

You should now have a Map with cities shown on them (like below)
withcities.png

Last edited Jan 8, 2015 at 8:10 AM by FObermaier, version 3