mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
MapTileLayer implementation
This commit is contained in:
parent
933cb7f2ba
commit
407f786640
|
|
@ -109,33 +109,24 @@ namespace MapControl
|
||||||
return finalSize;
|
return finalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task UpdateTileLayerAsync(bool tileSourceChanged)
|
protected override async Task UpdateTileLayerAsync(bool resetTiles)
|
||||||
{
|
{
|
||||||
var updateTiles = false;
|
|
||||||
|
|
||||||
if (ParentMap == null || ParentMap.MapProjection.Type != MapProjectionType.WebMercator)
|
if (ParentMap == null || ParentMap.MapProjection.Type != MapProjectionType.WebMercator)
|
||||||
{
|
{
|
||||||
updateTiles = TileMatrix != null;
|
|
||||||
TileMatrix = null;
|
TileMatrix = null;
|
||||||
|
Children.Clear();
|
||||||
|
|
||||||
|
await LoadTilesAsync(null, null); // stop TileImageLoader
|
||||||
}
|
}
|
||||||
else
|
else if (SetTileMatrix() || resetTiles)
|
||||||
{
|
{
|
||||||
if (tileSourceChanged)
|
|
||||||
{
|
|
||||||
Tiles = new TileCollection(); // clear all
|
|
||||||
updateTiles = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SetTileMatrix())
|
|
||||||
{
|
|
||||||
updateTiles = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetRenderTransform();
|
SetRenderTransform();
|
||||||
}
|
|
||||||
|
|
||||||
if (updateTiles)
|
if (resetTiles)
|
||||||
{
|
{
|
||||||
|
Tiles.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
UpdateTiles();
|
UpdateTiles();
|
||||||
|
|
||||||
await LoadTilesAsync(Tiles, SourceName);
|
await LoadTilesAsync(Tiles, SourceName);
|
||||||
|
|
|
||||||
|
|
@ -194,13 +194,13 @@ namespace MapControl
|
||||||
|
|
||||||
protected abstract void SetRenderTransform();
|
protected abstract void SetRenderTransform();
|
||||||
|
|
||||||
protected abstract Task UpdateTileLayerAsync(bool tileSourceChanged);
|
protected abstract Task UpdateTileLayerAsync(bool resetTiles);
|
||||||
|
|
||||||
private Task UpdateTileLayer(bool tileSourceChanged)
|
private Task UpdateTileLayer(bool resetTiles)
|
||||||
{
|
{
|
||||||
updateTimer.Stop();
|
updateTimer.Stop();
|
||||||
|
|
||||||
return UpdateTileLayerAsync(tileSourceChanged);
|
return UpdateTileLayerAsync(resetTiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
private async void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
pendingTiles?.Clear();
|
pendingTiles?.Clear();
|
||||||
|
|
||||||
if (tiles != null && tileSource != null)
|
if (tileSource != null && tiles != null && (tiles = tiles.Where(tile => tile.IsPending)).Any())
|
||||||
{
|
{
|
||||||
pendingTiles = new ConcurrentStack<Tile>(tiles.Where(tile => tile.IsPending).Reverse());
|
pendingTiles = new ConcurrentStack<Tile>(tiles.Reverse());
|
||||||
|
|
||||||
var tileCount = pendingTiles.Count;
|
var tileCount = pendingTiles.Count;
|
||||||
var taskCount = Math.Min(tileCount, MaxLoadTasks);
|
var taskCount = Math.Min(tileCount, MaxLoadTasks);
|
||||||
|
|
|
||||||
|
|
@ -89,9 +89,9 @@ namespace MapControl
|
||||||
return finalSize;
|
return finalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task UpdateTileLayerAsync(bool tileSourceChanged)
|
protected override async Task UpdateTileLayerAsync(bool resetTiles)
|
||||||
{
|
{
|
||||||
// tileSourceChanged is ignored here because it is always false.
|
// resetTiles is ignored here because it is always false.
|
||||||
|
|
||||||
if (ParentMap == null ||
|
if (ParentMap == null ||
|
||||||
!TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out WmtsTileMatrixSet tileMatrixSet))
|
!TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out WmtsTileMatrixSet tileMatrixSet))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue