MapDotNet UX Help

Tile Layers

Tile layers are instances of the TileLayer class.  Tile layers use, at a minimum, a Descriptor and a TileRequestor to obtain and display map tiles from exterior sources.  Tile layers can be created declaratively or in code.

Adding a Tile Layer Declaratively

<rim:TileLayer x:Name="MDNSTileLayer" FadeInDuration="0:0:0.5" ExcludeFromBackdrop="True" Descriptor="Sample">
        <Requestors:MDNSMapTileRequestor BleedRatio="1.25" />

This declaration is nested within the MapModel declaration.  See Using the RIM Controls for more details.

This is a typical tile layer declaration.  The tile requestor is an  MDNSMapTileRequestor.  Because this tile layer is using an MDNSMapTileRequestor, its Descriptor is the ID of the map to render.

Use the x:Name syntax to assign the TileLayer a name used to reference it in code-behind.  TileLayer has several useful properties, some of which are shown above.

Descriptor must always be set.  Expected Descriptor values differ based on the TileRequestor in use.  In some cases, string Descriptors declared in markup are replaced with other types of objects during tile layer initialization.  

ExcludeFromBackdrop should be set true for all but the base map to avoid the performance impact of rendering complex backdrops as new data loads..   

FadeInDuration is used to provide an attractive fade-in when images are loaded.

Opacity can be used when tile images are opaque but the base map needs to be visible through them.

A TileRenderer element is used in conjunction with a TileRequestor that returns vector data.  The only such requestor is the MapDotNet Geometry tile requestor.

A TileRequestor element must be provided to retrieve the actual tile content.

Use the following links for more details about setting up tile layers for particular data sources.

Adding a TileLayer in Code

  1. Create an instance of the appropriate TileRequestor class.
    BingMapsTileRequestor bing = new BingMapsTileRequestor();  
  2. Create an instance of TileLayer.  Either use the no-argument constructor or the constructor that takes a layer key and a TileRequestor.  The layer key is primarily used internally, but you will see this constructor in older code.  Newer versions of the RIM coltrols will generate the key if it is not provided.
    TileLayer myTileLayer = new TileLayer("newLayerKey", bing); 
  3. Add the tile layer to the map.  This cannot be done before the map controls are initialized.  Handle the map's InitializeMVCComplete event, or call InitializeMVC yourself.
  4. Assign an appropriate Descriptor to the tile layer.  This can be done before or after adding the layer to the map. 
    myTileLayer.Descriptor = "r"; 
    If you are assigning the Descriptor in code, it must be of the appropriate type, such as a MapRequest for an MDNSMapTileRequestor.  Some classes provide helper methods for this, for instance MDNSMapTileRequestor provides a BuildDescriptorAsync method that takes a map ID and completed and error actions and attempts to retrieve the appropriate map from the server specified by its EndpointAddress and build a MapRequest using it.  Your completed handler is responsible for assigning the MapRequest to the tile layer.

TileLayer Class in Detail

The TileLayer class defines a layer of tiled content presented within an IContentArea on your map. A TileLayer definition is added to your map via the map controller (e.g. myMap.MapController.AddTileLayer(...))  The MapView of the RIM control (e.g. accessed via myMap.MapView) has two pre-defined and pre-loaded (at construction) IContentAreas for displaying tiled content: ContentAreaMain and ContentAreaBackdrop. These IContentAreas hold presenter instances (QuadTileView) of rendered QuadTiles defined by their associated TileLayer.