Updated WmtsTileLayer

This commit is contained in:
ClemensFischer 2025-12-01 13:59:18 +01:00
parent 2ec4d8fa60
commit a223c32466
2 changed files with 9 additions and 9 deletions

View file

@ -28,8 +28,8 @@ namespace MapControl
public static readonly DependencyProperty CapabilitiesUriProperty = public static readonly DependencyProperty CapabilitiesUriProperty =
DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri)); DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri));
public static readonly DependencyProperty TileUriTemplateProperty = public static readonly DependencyProperty UriTemplateProperty =
DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(TileUriTemplate)); DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(UriTemplate));
public static readonly DependencyProperty LayerProperty = public static readonly DependencyProperty LayerProperty =
DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(Layer)); DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(Layer));
@ -55,10 +55,10 @@ namespace MapControl
/// The Uri template string used for the UriTemplate property of WmtsTileSource instances. /// The Uri template string used for the UriTemplate property of WmtsTileSource instances.
/// Usually set internally from WmtsCapabilities requested by a Loaded event handler. /// Usually set internally from WmtsCapabilities requested by a Loaded event handler.
/// </summary> /// </summary>
public string TileUriTemplate public string UriTemplate
{ {
get => (string)GetValue(TileUriTemplateProperty); get => (string)GetValue(UriTemplateProperty);
set => SetValue(TileUriTemplateProperty, value); set => SetValue(UriTemplateProperty, value);
} }
/// <summary> /// <summary>
@ -131,7 +131,7 @@ namespace MapControl
} }
else if (UpdateChildLayers(tileMatrixSet)) else if (UpdateChildLayers(tileMatrixSet))
{ {
var tileSource = new WmtsTileSource(tileMatrixSet, TileUriTemplate); var tileSource = new WmtsTileSource(UriTemplate, tileMatrixSet);
var cacheName = SourceName; var cacheName = SourceName;
if (!string.IsNullOrEmpty(cacheName)) if (!string.IsNullOrEmpty(cacheName))
@ -226,7 +226,7 @@ namespace MapControl
} }
Layer = capabilities.Layer; Layer = capabilities.Layer;
TileUriTemplate = capabilities.UriTemplate; UriTemplate = capabilities.UriTemplate;
UpdateTileCollection(); UpdateTileCollection();
} }

View file

@ -8,10 +8,10 @@ namespace MapControl
{ {
private readonly IList<WmtsTileMatrix> tileMatrixes; private readonly IList<WmtsTileMatrix> tileMatrixes;
public WmtsTileSource(WmtsTileMatrixSet tileMatrixSet, string uriTemplate) public WmtsTileSource(string uriTemplate, WmtsTileMatrixSet tileMatrixSet)
{ {
tileMatrixes = tileMatrixSet.TileMatrixes;
UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier); UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier);
tileMatrixes = tileMatrixSet.TileMatrixes;
} }
public override Uri GetUri(int zoomLevel, int column, int row) public override Uri GetUri(int zoomLevel, int column, int row)