From f1ea07504766d206d544a8fb33dbb7636484b7df Mon Sep 17 00:00:00 2001 From: ClemensF Date: Fri, 20 Mar 2020 21:09:19 +0100 Subject: [PATCH] Version 4.17.0: Added support for WMTS --- MapControl/Shared/WmtsTileLayer.cs | 5 +++-- MapControl/Shared/WmtsTileSource.cs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/MapControl/Shared/WmtsTileLayer.cs b/MapControl/Shared/WmtsTileLayer.cs index 3bd1039a..c5db770c 100644 --- a/MapControl/Shared/WmtsTileLayer.cs +++ b/MapControl/Shared/WmtsTileLayer.cs @@ -20,7 +20,8 @@ namespace MapControl public class WmtsTileLayer : MapTileLayerBase { public static readonly DependencyProperty CapabilitiesUriProperty = DependencyProperty.Register( - nameof(CapabilitiesUri), typeof(Uri), typeof(WmtsTileLayer), new PropertyMetadata(null)); + nameof(CapabilitiesUri), typeof(Uri), typeof(WmtsTileLayer), + new PropertyMetadata(null, (o, e) => ((WmtsTileLayer)o).TileMatrixSet = null)); public static readonly DependencyProperty LayerIdentifierProperty = DependencyProperty.Register( nameof(LayerIdentifier), typeof(string), typeof(WmtsTileLayer), new PropertyMetadata(null)); @@ -169,7 +170,7 @@ namespace MapControl private async void OnLoaded(object sender, RoutedEventArgs e) { - if (CapabilitiesUri != null) + if (TileMatrixSet == null && CapabilitiesUri != null) { try { diff --git a/MapControl/Shared/WmtsTileSource.cs b/MapControl/Shared/WmtsTileSource.cs index 21606ff6..f0902dd8 100644 --- a/MapControl/Shared/WmtsTileSource.cs +++ b/MapControl/Shared/WmtsTileSource.cs @@ -19,17 +19,17 @@ namespace MapControl public override Uri GetUri(int x, int y, int zoomLevel) { - if (zoomLevel < 0 || zoomLevel >= tileMatrixes.Count) + Uri uri = null; + + if (zoomLevel >= 0 && zoomLevel < tileMatrixes.Count) { - return null; + uri = new Uri(UriFormat + .Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier) + .Replace("{TileCol}", x.ToString()) + .Replace("{TileRow}", y.ToString())); } - var url = UriFormat - .Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier) - .Replace("{TileCol}", x.ToString()) - .Replace("{TileRow}", y.ToString()); - - return new Uri(url); + return uri; } } }