mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Updated WmtsTileLayer
This commit is contained in:
parent
0f3635b97a
commit
733c3d1266
|
|
@ -148,7 +148,7 @@ namespace MapControl
|
||||||
|
|
||||||
private bool SetTileMatrix()
|
private bool SetTileMatrix()
|
||||||
{
|
{
|
||||||
// Add 0.001 to avoid rounding issues.
|
// Add 0.001 to avoid floating point precision.
|
||||||
//
|
//
|
||||||
var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel - ZoomLevelOffset + 0.001);
|
var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel - ZoomLevelOffset + 0.001);
|
||||||
var tileMatrixScale = MapBase.ZoomLevelToScale(tileMatrixZoomLevel);
|
var tileMatrixScale = MapBase.ZoomLevelToScale(tileMatrixZoomLevel);
|
||||||
|
|
|
||||||
|
|
@ -148,13 +148,13 @@ namespace MapControl
|
||||||
//
|
//
|
||||||
var maxScale = 1.001 * ParentMap.ViewTransform.Scale;
|
var maxScale = 1.001 * ParentMap.ViewTransform.Scale;
|
||||||
var tileMatrixes = tileMatrixSet.TileMatrixes.Where(matrix => matrix.Scale <= maxScale).ToList();
|
var tileMatrixes = tileMatrixSet.TileMatrixes.Where(matrix => matrix.Scale <= maxScale).ToList();
|
||||||
var childLayers = ChildLayers.Where(layer => tileMatrixes.Contains(layer.WmtsTileMatrix)).ToList();
|
|
||||||
var tilesChanged = false;
|
|
||||||
|
|
||||||
Children.Clear();
|
if (tileMatrixes.Count == 0)
|
||||||
|
|
||||||
if (tileMatrixes.Count > 0)
|
|
||||||
{
|
{
|
||||||
|
Children.Clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var maxLayers = Math.Max(MaxBackgroundLevels, 0) + 1;
|
var maxLayers = Math.Max(MaxBackgroundLevels, 0) + 1;
|
||||||
|
|
||||||
if (!IsBaseMapLayer)
|
if (!IsBaseMapLayer)
|
||||||
|
|
@ -170,12 +170,18 @@ namespace MapControl
|
||||||
tileMatrixes = tileMatrixes.GetRange(tileMatrixes.Count - maxLayers, maxLayers);
|
tileMatrixes = tileMatrixes.GetRange(tileMatrixes.Count - maxLayers, maxLayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get reusable layers.
|
||||||
|
//
|
||||||
|
var layers = ChildLayers.Where(layer => tileMatrixes.Contains(layer.WmtsTileMatrix)).ToList();
|
||||||
|
var tilesChanged = false;
|
||||||
|
|
||||||
|
Children.Clear();
|
||||||
|
|
||||||
foreach (var tileMatrix in tileMatrixes)
|
foreach (var tileMatrix in tileMatrixes)
|
||||||
{
|
{
|
||||||
// Reuse existing WmtsTileMatrixLayer or create a new one with the
|
// Pass index of tileMatrix in tileMatrixSet.TileMatrixes as zoom level to WmtsTileMatrixLayer ctor.
|
||||||
// index of tileMatrix in tileMatrixSet.TileMatrixes as zoom level.
|
|
||||||
//
|
//
|
||||||
var layer = childLayers.FirstOrDefault(layer => layer.WmtsTileMatrix == tileMatrix) ??
|
var layer = layers.FirstOrDefault(layer => layer.WmtsTileMatrix == tileMatrix) ??
|
||||||
new WmtsTileMatrixLayer(tileMatrix, tileMatrixSet.TileMatrixes.IndexOf(tileMatrix));
|
new WmtsTileMatrixLayer(tileMatrix, tileMatrixSet.TileMatrixes.IndexOf(tileMatrix));
|
||||||
|
|
||||||
if (layer.UpdateTiles(ParentMap.ViewTransform, ParentMap.ActualWidth, ParentMap.ActualHeight))
|
if (layer.UpdateTiles(ParentMap.ViewTransform, ParentMap.ActualWidth, ParentMap.ActualHeight))
|
||||||
|
|
@ -187,7 +193,6 @@ namespace MapControl
|
||||||
|
|
||||||
Children.Add(layer);
|
Children.Add(layer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return tilesChanged;
|
return tilesChanged;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue