Update MapTileLayerBase.cs

This commit is contained in:
ClemensF 2020-10-25 17:49:18 +01:00
parent eaef66ebf0
commit f54626ea21

View file

@ -59,12 +59,7 @@ namespace MapControl
TileImageLoader = tileImageLoader; TileImageLoader = tileImageLoader;
updateTimer = new DispatcherTimer { Interval = UpdateInterval }; updateTimer = new DispatcherTimer { Interval = UpdateInterval };
updateTimer.Tick += (s, e) => Update();
updateTimer.Tick += (s, e) =>
{
updateTimer.Stop();
UpdateTileLayer();
};
MapPanel.InitMapElement(this); MapPanel.InitMapElement(this);
} }
@ -149,8 +144,6 @@ namespace MapControl
get { return parentMap; } get { return parentMap; }
set set
{ {
updateTimer.Stop();
if (parentMap != null) if (parentMap != null)
{ {
parentMap.ViewportChanged -= OnViewportChanged; parentMap.ViewportChanged -= OnViewportChanged;
@ -163,7 +156,7 @@ namespace MapControl
parentMap.ViewportChanged += OnViewportChanged; parentMap.ViewportChanged += OnViewportChanged;
} }
UpdateTileLayer(); Update();
} }
} }
@ -171,8 +164,7 @@ namespace MapControl
{ {
if (Children.Count == 0 || e.ProjectionChanged || Math.Abs(e.LongitudeOffset) > 180d) if (Children.Count == 0 || e.ProjectionChanged || Math.Abs(e.LongitudeOffset) > 180d)
{ {
updateTimer.Stop(); Update(); // update immediately when projection has changed or center has moved across 180° longitude
UpdateTileLayer(); // update immediately when projection has changed or center has moved across 180° longitude
} }
else else
{ {
@ -190,6 +182,12 @@ namespace MapControl
} }
} }
private void Update()
{
updateTimer.Stop();
UpdateTileLayer();
}
protected abstract void UpdateTileLayer(); protected abstract void UpdateTileLayer();
protected abstract void SetRenderTransform(); protected abstract void SetRenderTransform();