mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Version 4.8.0: Improved WPF MapPolyline and MapPolygon accuracy.
This commit is contained in:
parent
de4ba0765a
commit
5bc42d1f07
19 changed files with 77 additions and 172 deletions
|
|
@ -116,6 +116,12 @@
|
|||
<Compile Include="..\Shared\MapPanel.cs">
|
||||
<Link>MapPanel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\MapPolygon.cs">
|
||||
<Link>MapPolygon.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\MapPolyline.cs">
|
||||
<Link>MapPolyline.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\MapProjection.cs">
|
||||
<Link>MapProjection.cs</Link>
|
||||
</Compile>
|
||||
|
|
@ -171,8 +177,6 @@
|
|||
<Compile Include="MapMultiPolygon.WPF.cs" />
|
||||
<Compile Include="MapOverlay.WPF.cs" />
|
||||
<Compile Include="MapPanel.WPF.cs" />
|
||||
<Compile Include="MapPolygon.WPF.cs" />
|
||||
<Compile Include="MapPolyline.WPF.cs" />
|
||||
<Compile Include="MapShape.WPF.cs" />
|
||||
<Compile Include="TileImageLoader.WPF.cs" />
|
||||
<Compile Include="ImageLoader.WPF.cs" />
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MapControl
|
|||
{
|
||||
foreach (var polygon in Polygons)
|
||||
{
|
||||
AddPolylineFigure(figures, polygon, true);
|
||||
AddPolylineFigures(figures, polygon, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2018 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// A polygon defined by a collection of Locations.
|
||||
/// </summary>
|
||||
public class MapPolygon : MapShape
|
||||
{
|
||||
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
|
||||
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolygon),
|
||||
new PropertyMetadata(null, (o, e) => ((MapPolygon)o).DataCollectionPropertyChanged(e)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Locations that define the polygon points.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(LocationCollectionConverter))]
|
||||
public IEnumerable<Location> Locations
|
||||
{
|
||||
get { return (IEnumerable<Location>)GetValue(LocationsProperty); }
|
||||
set { SetValue(LocationsProperty, value); }
|
||||
}
|
||||
|
||||
protected override void UpdateData()
|
||||
{
|
||||
var figures = ((PathGeometry)Data).Figures;
|
||||
figures.Clear();
|
||||
|
||||
if (ParentMap != null)
|
||||
{
|
||||
AddPolylineFigure(figures, Locations, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2018 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// A polyline defined by a collection of Locations.
|
||||
/// </summary>
|
||||
public class MapPolyline : MapShape
|
||||
{
|
||||
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
|
||||
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolyline),
|
||||
new PropertyMetadata(null, (o, e) => ((MapPolyline)o).DataCollectionPropertyChanged(e)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Locations that define the polyline points.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(LocationCollectionConverter))]
|
||||
public IEnumerable<Location> Locations
|
||||
{
|
||||
get { return (IEnumerable<Location>)GetValue(LocationsProperty); }
|
||||
set { SetValue(LocationsProperty, value); }
|
||||
}
|
||||
|
||||
protected override void UpdateData()
|
||||
{
|
||||
var figures = ((PathGeometry)Data).Figures;
|
||||
figures.Clear();
|
||||
|
||||
if (ParentMap != null)
|
||||
{
|
||||
AddPolylineFigure(figures, Locations, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,50 +21,9 @@ namespace MapControl
|
|||
get { return Data; }
|
||||
}
|
||||
|
||||
partial void SetDataTransform()
|
||||
{
|
||||
if (parentMap != null)
|
||||
{
|
||||
var transform = new TransformGroup();
|
||||
var offsetX = GetLongitudeOffset() * parentMap.MapProjection.TrueScale;
|
||||
|
||||
transform.Children.Add(new TranslateTransform(offsetX, 0d));
|
||||
transform.Children.Add(parentMap.MapProjection.ViewportTransform);
|
||||
|
||||
Data.Transform = transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.Transform = Transform.Identity;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
var transform = (TransformGroup)Data.Transform;
|
||||
var offset = (TranslateTransform)transform.Children[0];
|
||||
|
||||
offset.X = GetLongitudeOffset() * parentMap.MapProjection.TrueScale;
|
||||
|
||||
if (e.ProjectionChanged)
|
||||
{
|
||||
transform.Children[1] = parentMap.MapProjection.ViewportTransform;
|
||||
}
|
||||
|
||||
if (e.ProjectionChanged || parentMap.MapProjection.IsAzimuthal)
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
else if (Fill != null)
|
||||
{
|
||||
InvalidateVisual(); // Fill brush may be rendered only partially or not at all
|
||||
}
|
||||
}
|
||||
|
||||
bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
|
||||
{
|
||||
UpdateData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -85,11 +44,17 @@ namespace MapControl
|
|||
UpdateData();
|
||||
}
|
||||
|
||||
protected void AddPolylineFigure(PathFigureCollection figures, IEnumerable<Location> locations, bool closed)
|
||||
protected void AddPolylineFigures(PathFigureCollection figures, IEnumerable<Location> locations, bool closed)
|
||||
{
|
||||
if (locations != null && locations.Count() >= 2)
|
||||
{
|
||||
var points = locations.Select(loc => LocationToPoint(loc));
|
||||
var offset = GetLongitudeOffset();
|
||||
if (offset != 0d)
|
||||
{
|
||||
locations = locations.Select(loc => new Location(loc.Latitude, loc.Longitude + offset));
|
||||
}
|
||||
|
||||
var points = locations.Select(loc => LocationToViewportPoint(loc));
|
||||
var figure = new PathFigure
|
||||
{
|
||||
StartPoint = points.First(),
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("4.7.1")]
|
||||
[assembly: AssemblyFileVersion("4.7.1")]
|
||||
[assembly: AssemblyVersion("4.8.0")]
|
||||
[assembly: AssemblyFileVersion("4.8.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue