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:

xmlns:rim="clr-namespace:ISC.RIM.Silverlight;assembly=ISC.RIM.Silverlight"
xmlns:Projections="clr-namespace:ISC.RIM.Silverlight.Projections;assembly=ISC.RIM.Silverlight"
xmlns:Requestors="clr-namespace:ISC.RIM.Silverlight.Requestor;assembly=ISC.RIM.Silverlight"

Namespace declarations for WPF:

xmlns:rim="clr-namespace:ISC.RIM.WPF;assembly=ISC.RIM.Silverlight"
xmlns:Projections="clr-namespace:ISC.RIM.WPF.Projections;assembly=ISC.RIM.Silverlight"
xmlns:Requestors="clr-namespace:ISC.RIM.WPF.Requestor;assembly=ISC.RIM.Silverlight"

Control markup:

<rim:Map MDNSAddress="http://demo.mapdotnet.com/MDNUXiSDKService/">

    <rim:Map.TileProjection>
        <Projections:SphericalMercatorTileProjection />
    </rim:Map.TileProjection>

    <rim:Map.MapModel>
        <rim:MapModel>

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

        </rim:MapModel>
    </rim:Map.MapModel>

</rim:Map>

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">
    <rim:TileLayer.TileRequestor>
        <Requestors:WMSTileRequestor EndpointAddress="http://gis.srh.noaa.gov/ArcGIS/services/RIDGERadar/mapserver/WMSServer"
                                                      TransparentBackground="True"
                                                      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">
    <rim:TileLayer.TileRequestor>
        <Requestors:WMSTileRequestor EndpointAddress="http://gis.srh.noaa.gov/ArcGIS/services/RIDGERadar/mapserver/WMSServer"
                                                      TransparentBackground="True"
                                                      ImageFormat="image/png"
                                                      UseProxy="False"
                                                      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">
    <rim:TileLayer.TileRequestor>
        <Requestors:WMSTileRequestor EndpointAddress="http://apps.mapdotnet.com/MDNUXiSDKService/OGC/WMS.ashx?map=SampleWithBaseMap&amp;"
                                     TransparentBackground="False"
                                     ImageFormat="image/png"
                                     UseProxy="False"
                                     GeographicOverride="False"
                                     BuildReferenceOnly="False" />
    </rim:TileLayer.TileRequestor>
</rim:TileLayer>      

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
myMap.MapController.AddTileLayer(wmsTileLayer);