MapDotNet UX Help

Add a WMS TileLayer to your Map

Tile layers can be added either declaratively or in code.

Adding a WMS Map Tile Layer Declaratively

You must first declare the map itself.  The map declaration should include the address of the MapDotNet UX Web Service instance used.  You must also set the Map.TileProjection property and Map.MapModel properties.  Your tile layers will be nested within the map model.

Namespace declarations for Silverlight:


Namespace declarations for WPF:


Control markup:

<rim:Map MDNSAddress="">

        <Projections:SphericalMercatorTileProjection />


     	<!-- Tile layers go here. -->



See Using the RIM Controls for more about the map declaration.

The declaration for any tile layer includes a Descriptor and a Requestor.  The Requestor for a WMS tile layer is an instance of the WMSTileRequestor class.  The Descriptor should be the WMS layer name, such as "r" for roads or "a" for aerials.  The TileLayer can be assigned a Name to reference it in the code-behind.  Setting the Opacity and ExcludeFromBackdrop properties of the TileLayer are recommended.

Note that several parameters are set on the WMSTileRequestor.  EndpointAddress is required.  ImageFormat defaults to "image/png".  Params are additional parameters that may be required by some WMS servers.  These are sometimes set directly on the EndopintAddress instead.

Under Silverlight, you must use a either use a proxy for the WMS requests- which is the default behavior- or set BuildReferenceOnly to true.

If you have installed the MapDotNet UX SDK, the path to the proxy (from the MapDotNet installation folder, typically C:\Program Files\MapDotNet\[your product version]\) is Apps\Silverlight\Sample\SampleWeb\ClientBin\proxy.ashx. Simply copy this to your ClientBin and include it in your project.  The proxy requests the WMS tile from the application server and relays it to the client, thus getting around Silverlight client access restrictions

<rim:TileLayer Opacity="0.75" ExcludeFromBackdrop="True" Descriptor="nexrad">
        <Requestors:WMSTileRequestor EndpointAddress=""
                                                      ImageFormat="image/png" /> </rim:TileLayer.TileRequestor> </rim:TileLayer>

If you instead set BuildReferenceOnly  to true, the client assigns the WMS URL directly to a Silverlight Image object.  This gets around the client access problem but gives you no way to detect tile errors.

<rim:TileLayer FadeInDuration="0:0:0.5" Opacity="0.75" ExcludeFromBackdrop="True" Descriptor="nexrad">
        <Requestors:WMSTileRequestor EndpointAddress=""
                                                      BuildReferenceOnly="True" /> </rim:TileLayer.TileRequestor> </rim:TileLayer>

If you are using a MapDotNet UX WMS Service, the above constraints do not apply as the MapDotNet UX service should have an appropriate ClientAccessPolicy file in place.  If your map is in Spherical Mercator, you can also set GeographicOverride to false to retrieve tiles in Spherical Mercator.  By default, the WMSTileRequestor requests tiles in geographic coordinates and stretches them.  Most WMS services support WGS 84, few others besides MapDotNet support Spherical Mercator.

<rim:TileLayer FadeInDuration="0:0:0.5" Descriptor="Default">
        <Requestors:WMSTileRequestor EndpointAddress=";"
                                     BuildReferenceOnly="False" />

The declarative approach is the preferred way to add tile layers.

Adding a WMS Tile Layer in Code

To add a TileLayer from a WMS source to the RIM control perform the steps below after you have set up your RIM control.

WPF and Silverlight (c#)

// create an ITileRequestor implementation for a WMS layer
var wmsRequestor = new WMSTileRequestor();

// set the URI to the WMS
wmsRequestor.EndpointAddress = "http://yourWMSserver";

// create a new tile layer using the above requestor
var wmsTileLayer = new TileLayer("WMS", wmsRequestor);

// layer opacity - 0.0 fully transparent, 1.0 fully opaque
wmsTileLayer.Opacity = 1.0;

// the descriptor is the WMS layer name
wmsTileLayer.Descriptor = "wms_layer_name";

// add the layer to your map