mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Implemented LocationAnimator
This commit is contained in:
parent
3706709cfc
commit
abe3bb75f9
|
|
@ -10,7 +10,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public override Location Interpolate(double progress, Location oldValue, Location newValue)
|
public override Location Interpolate(double progress, Location oldValue, Location newValue)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
return new Location(
|
||||||
|
(1d - progress) * oldValue.Latitude + progress * newValue.Latitude,
|
||||||
|
(1d - progress) * oldValue.Longitude + progress * newValue.Longitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,16 @@ namespace MapControl
|
||||||
|
|
||||||
static MapBase()
|
static MapBase()
|
||||||
{
|
{
|
||||||
|
Animation.RegisterCustomAnimator<Location, LocationAnimator>();
|
||||||
|
|
||||||
ClipToBoundsProperty.OverrideDefaultValue(typeof(MapBase), true);
|
ClipToBoundsProperty.OverrideDefaultValue(typeof(MapBase), true);
|
||||||
|
|
||||||
CenterProperty.Changed.AddClassHandler<MapBase, Location>(
|
CenterProperty.Changed.AddClassHandler<MapBase, Location>(
|
||||||
(map, args) => map.CenterPropertyChanged(args.NewValue.Value));
|
(map, args) => map.CenterPropertyChanged(args.NewValue.Value));
|
||||||
|
|
||||||
|
TargetCenterProperty.Changed.AddClassHandler<MapBase, Location>(
|
||||||
|
async (map, args) => await map.TargetCenterPropertyChanged(args.NewValue.Value));
|
||||||
|
|
||||||
ZoomLevelProperty.Changed.AddClassHandler<MapBase, double>(
|
ZoomLevelProperty.Changed.AddClassHandler<MapBase, double>(
|
||||||
(map, args) => map.ZoomLevelPropertyChanged(args.NewValue.Value));
|
(map, args) => map.ZoomLevelPropertyChanged(args.NewValue.Value));
|
||||||
|
|
||||||
|
|
@ -161,6 +166,41 @@ namespace MapControl
|
||||||
if (!internalPropertyChange)
|
if (!internalPropertyChange)
|
||||||
{
|
{
|
||||||
UpdateTransform();
|
UpdateTransform();
|
||||||
|
|
||||||
|
if (centerAnimation == null)
|
||||||
|
{
|
||||||
|
SetValueInternal(TargetCenterProperty, center);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task TargetCenterPropertyChanged(Location targetCenter)
|
||||||
|
{
|
||||||
|
if (!internalPropertyChange && !targetCenter.Equals(Center))
|
||||||
|
{
|
||||||
|
centerCts?.Cancel();
|
||||||
|
|
||||||
|
centerAnimation = new Animation
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Forward,
|
||||||
|
Duration = AnimationDuration,
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new KeyFrame
|
||||||
|
{
|
||||||
|
KeyTime = AnimationDuration,
|
||||||
|
Setters = { new Setter(CenterProperty, new Location(targetCenter.Latitude, ConstrainedLongitude(targetCenter.Longitude))) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
centerCts = new CancellationTokenSource();
|
||||||
|
|
||||||
|
await centerAnimation.RunAsync(this, centerCts.Token);
|
||||||
|
|
||||||
|
centerCts.Dispose();
|
||||||
|
centerCts = null;
|
||||||
|
centerAnimation = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,27 +15,32 @@
|
||||||
<PackageId>XAML.MapControl</PackageId>
|
<PackageId>XAML.MapControl</PackageId>
|
||||||
<DefineConstants>AVALONIA</DefineConstants>
|
<DefineConstants>AVALONIA</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\Shared\BoundingBox.cs" Link="BoundingBox.cs" />
|
<Compile Include="..\Shared\BoundingBox.cs" Link="BoundingBox.cs" />
|
||||||
<Compile Include="..\Shared\ImageFileCache.cs" Link="ImageFileCache.cs" />
|
<Compile Include="..\Shared\ImageFileCache.cs" Link="ImageFileCache.cs" />
|
||||||
<Compile Include="..\Shared\ImageLoader.cs" Link="ImageLoader.cs" />
|
<Compile Include="..\Shared\ImageLoader.cs" Link="ImageLoader.cs" />
|
||||||
<Compile Include="..\Shared\Location.cs" Link="Location.cs" />
|
<Compile Include="..\Shared\Location.cs" Link="Location.cs" />
|
||||||
<Compile Include="..\Shared\LocationCollection.cs" Link="LocationCollection.cs" />
|
<Compile Include="..\Shared\LocationCollection.cs" Link="LocationCollection.cs" />
|
||||||
<Compile Include="..\Shared\MapBaseCommon.cs" Link="MapBaseCommon.cs" />
|
<Compile Include="..\Shared\MapBaseCommon.cs" Link="MapBaseCommon.cs" />
|
||||||
<Compile Include="..\Shared\MapPanel.cs" Link="MapPanel.cs" />
|
<Compile Include="..\Shared\MapPanel.cs" Link="MapPanel.cs" />
|
||||||
<Compile Include="..\Shared\MapProjection.cs" Link="MapProjection.cs" />
|
<Compile Include="..\Shared\MapProjection.cs" Link="MapProjection.cs" />
|
||||||
<Compile Include="..\Shared\MapTileLayer.cs" Link="MapTileLayer.cs" />
|
<Compile Include="..\Shared\MapTileLayer.cs" Link="MapTileLayer.cs" />
|
||||||
<Compile Include="..\Shared\MapTileLayerBase.cs" Link="MapTileLayerBase.cs" />
|
<Compile Include="..\Shared\MapTileLayerBase.cs" Link="MapTileLayerBase.cs" />
|
||||||
<Compile Include="..\Shared\Tile.cs" Link="Tile.cs" />
|
<Compile Include="..\Shared\Tile.cs" Link="Tile.cs" />
|
||||||
<Compile Include="..\Shared\TileCollection.cs" Link="TileCollection.cs" />
|
<Compile Include="..\Shared\TileCollection.cs" Link="TileCollection.cs" />
|
||||||
<Compile Include="..\Shared\TileImageLoader.cs" Link="TileImageLoader.cs" />
|
<Compile Include="..\Shared\TileImageLoader.cs" Link="TileImageLoader.cs" />
|
||||||
<Compile Include="..\Shared\TileMatrix.cs" Link="TileMatrix.cs" />
|
<Compile Include="..\Shared\TileMatrix.cs" Link="TileMatrix.cs" />
|
||||||
<Compile Include="..\Shared\TileSource.cs" Link="TileSource.cs" />
|
<Compile Include="..\Shared\TileSource.cs" Link="TileSource.cs" />
|
||||||
<Compile Include="..\Shared\ViewportChangedEventArgs.cs" Link="ViewportChangedEventArgs.cs" />
|
<Compile Include="..\Shared\ViewportChangedEventArgs.cs" Link="ViewportChangedEventArgs.cs" />
|
||||||
<Compile Include="..\Shared\ViewRect.cs" Link="ViewRect.cs" />
|
<Compile Include="..\Shared\ViewRect.cs" Link="ViewRect.cs" />
|
||||||
<Compile Include="..\Shared\WebMercatorProjection.cs" Link="WebMercatorProjection.cs" />
|
<Compile Include="..\Shared\WebMercatorProjection.cs" Link="WebMercatorProjection.cs" />
|
||||||
<Compile Include="..\WPF\Timer.WPF.cs" Link="Timer.WPF.cs" />
|
<Compile Include="..\WPF\Timer.WPF.cs" Link="Timer.WPF.cs" />
|
||||||
<Compile Include="..\WPF\TypeConverters.WPF.cs" Link="TypeConverters.WPF.cs" />
|
<Compile Include="..\WPF\TypeConverters.WPF.cs" Link="TypeConverters.WPF.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\..\MapControl.snk" Link="MapControl.snk" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue