mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 1.9.0:
- added MapBase.ZoomToBounds method - fixed coercing property values in MapBase - improved Location property handling in MapPanel to keep viewport positions near map center - use common view model in sample applications
This commit is contained in:
parent
9f4ab0f3e3
commit
5eafa751f8
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -405,6 +405,27 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the TargetZoomLevel and TargetCenter properties such that the specified bounding box
|
||||
/// fits into the current viewport. The TargetHeading property is set to zero.
|
||||
/// </summary>
|
||||
public void ZoomToBounds(Location southWest, Location northEast)
|
||||
{
|
||||
if (southWest.Latitude < northEast.Latitude && southWest.Longitude < northEast.Longitude)
|
||||
{
|
||||
var p1 = MapTransform.Transform(southWest);
|
||||
var p2 = MapTransform.Transform(northEast);
|
||||
var lonScale = ActualWidth / (p2.X - p1.X) * 360d / TileSource.TileSize;
|
||||
var latScale = ActualHeight / (p2.Y - p1.Y) * 360d / TileSource.TileSize;
|
||||
var lonZoom = Math.Log(lonScale, 2d);
|
||||
var latZoom = Math.Log(latScale, 2d);
|
||||
|
||||
TargetZoomLevel = Math.Min(lonZoom, latZoom);
|
||||
TargetCenter = MapTransform.Transform(new Point((p1.X + p2.X) / 2d, (p1.Y + p2.Y) / 2d));
|
||||
TargetHeading = 0d;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnViewportChanged()
|
||||
{
|
||||
base.OnViewportChanged();
|
||||
|
|
@ -551,8 +572,14 @@ namespace MapControl
|
|||
internalPropertyChange = false;
|
||||
}
|
||||
|
||||
private bool CoerceLocation(Location location, double latitudeEpsilon = 0d)
|
||||
private bool CoerceLocation(ref Location location, double latitudeEpsilon = 0d)
|
||||
{
|
||||
if (location == null)
|
||||
{
|
||||
location = new Location();
|
||||
return true;
|
||||
}
|
||||
|
||||
var maxLatitude = mapTransform.MaxLatitude + latitudeEpsilon;
|
||||
var latitude = Math.Min(Math.Max(location.Latitude, -maxLatitude), maxLatitude);
|
||||
var longitude = Location.NormalizeLongitude(location.Longitude);
|
||||
|
|
@ -567,9 +594,9 @@ namespace MapControl
|
|||
return false;
|
||||
}
|
||||
|
||||
private void CoerceCenterProperty(DependencyProperty property, Location center)
|
||||
private void CoerceCenterProperty(DependencyProperty property, ref Location center)
|
||||
{
|
||||
if (CoerceLocation(center))
|
||||
if (CoerceLocation(ref center))
|
||||
{
|
||||
InternalSetValue(property, center);
|
||||
}
|
||||
|
|
@ -579,7 +606,7 @@ namespace MapControl
|
|||
{
|
||||
if (!internalPropertyChange)
|
||||
{
|
||||
CoerceCenterProperty(CenterProperty, center);
|
||||
CoerceCenterProperty(CenterProperty, ref center);
|
||||
ResetTransformOrigin();
|
||||
UpdateTransform();
|
||||
|
||||
|
|
@ -595,9 +622,9 @@ namespace MapControl
|
|||
{
|
||||
if (!internalPropertyChange)
|
||||
{
|
||||
CoerceCenterProperty(TargetCenterProperty, targetCenter);
|
||||
CoerceCenterProperty(TargetCenterProperty, ref targetCenter);
|
||||
|
||||
if (!targetCenter.Equals(Center))
|
||||
if (targetCenter.Latitude != Center.Latitude || targetCenter.Longitude != Center.Longitude)
|
||||
{
|
||||
if (centerAnimation != null)
|
||||
{
|
||||
|
|
@ -652,9 +679,11 @@ namespace MapControl
|
|||
|
||||
if (coercedValue != minZoomLevel)
|
||||
{
|
||||
InternalSetValue(MinZoomLevelProperty, coercedValue);
|
||||
minZoomLevel = coercedValue;
|
||||
InternalSetValue(MinZoomLevelProperty, minZoomLevel);
|
||||
}
|
||||
else if (ZoomLevel < minZoomLevel)
|
||||
|
||||
if (ZoomLevel < minZoomLevel)
|
||||
{
|
||||
ZoomLevel = minZoomLevel;
|
||||
}
|
||||
|
|
@ -666,32 +695,32 @@ namespace MapControl
|
|||
|
||||
if (coercedValue != maxZoomLevel)
|
||||
{
|
||||
InternalSetValue(MaxZoomLevelProperty, coercedValue);
|
||||
maxZoomLevel = coercedValue;
|
||||
InternalSetValue(MaxZoomLevelProperty, maxZoomLevel);
|
||||
}
|
||||
else if (ZoomLevel > maxZoomLevel)
|
||||
|
||||
if (ZoomLevel > maxZoomLevel)
|
||||
{
|
||||
ZoomLevel = maxZoomLevel;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CoerceZoomLevelProperty(DependencyProperty property, ref double zoomLevel)
|
||||
private void CoerceZoomLevelProperty(DependencyProperty property, ref double zoomLevel)
|
||||
{
|
||||
var coercedValue = Math.Min(Math.Max(zoomLevel, MinZoomLevel), MaxZoomLevel);
|
||||
|
||||
if (coercedValue != zoomLevel)
|
||||
{
|
||||
InternalSetValue(property, coercedValue);
|
||||
return true;
|
||||
zoomLevel = coercedValue;
|
||||
InternalSetValue(property, zoomLevel);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ZoomLevelPropertyChanged(double zoomLevel)
|
||||
{
|
||||
if (!internalPropertyChange &&
|
||||
!CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel))
|
||||
if (!internalPropertyChange)
|
||||
{
|
||||
CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel);
|
||||
UpdateTransform();
|
||||
|
||||
if (zoomLevelAnimation == null)
|
||||
|
|
@ -703,25 +732,28 @@ namespace MapControl
|
|||
|
||||
private void TargetZoomLevelPropertyChanged(double targetZoomLevel)
|
||||
{
|
||||
if (!internalPropertyChange &&
|
||||
!CoerceZoomLevelProperty(TargetZoomLevelProperty, ref targetZoomLevel) &&
|
||||
targetZoomLevel != ZoomLevel)
|
||||
if (!internalPropertyChange)
|
||||
{
|
||||
if (zoomLevelAnimation != null)
|
||||
CoerceZoomLevelProperty(TargetZoomLevelProperty, ref targetZoomLevel);
|
||||
|
||||
if (targetZoomLevel != ZoomLevel)
|
||||
{
|
||||
zoomLevelAnimation.Completed -= ZoomLevelAnimationCompleted;
|
||||
if (zoomLevelAnimation != null)
|
||||
{
|
||||
zoomLevelAnimation.Completed -= ZoomLevelAnimationCompleted;
|
||||
}
|
||||
|
||||
zoomLevelAnimation = new DoubleAnimation
|
||||
{
|
||||
To = targetZoomLevel,
|
||||
Duration = AnimationDuration,
|
||||
EasingFunction = AnimationEasingFunction,
|
||||
FillBehavior = FillBehavior.HoldEnd
|
||||
};
|
||||
|
||||
zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted;
|
||||
this.BeginAnimation(ZoomLevelProperty, zoomLevelAnimation);
|
||||
}
|
||||
|
||||
zoomLevelAnimation = new DoubleAnimation
|
||||
{
|
||||
To = targetZoomLevel,
|
||||
Duration = AnimationDuration,
|
||||
EasingFunction = AnimationEasingFunction,
|
||||
FillBehavior = FillBehavior.HoldEnd
|
||||
};
|
||||
|
||||
zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted;
|
||||
this.BeginAnimation(ZoomLevelProperty, zoomLevelAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -742,12 +774,12 @@ namespace MapControl
|
|||
|
||||
private void CoerceHeadingProperty(DependencyProperty property, ref double heading)
|
||||
{
|
||||
var coercedValue = (heading >= -180d && heading <= 360d) ?
|
||||
heading : (((heading % 360d) + 360d) % 360d);
|
||||
var coercedValue = (heading >= -180d && heading <= 360d) ? heading : (((heading % 360d) + 360d) % 360d);
|
||||
|
||||
if (coercedValue != heading)
|
||||
{
|
||||
InternalSetValue(property, coercedValue);
|
||||
heading = coercedValue;
|
||||
InternalSetValue(property, heading);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -826,7 +858,7 @@ namespace MapControl
|
|||
{
|
||||
center = ViewportPointToLocation(new Point(RenderSize.Width / 2d, RenderSize.Height / 2d));
|
||||
|
||||
var coerced = CoerceLocation(center, 1e-3);
|
||||
var coerced = CoerceLocation(ref center, 1e-3);
|
||||
|
||||
InternalSetValue(CenterProperty, center);
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,6 @@ namespace MapControl
|
|||
{
|
||||
for (var lon = labelsStart.Longitude; lon <= end.Longitude; lon += spacing)
|
||||
{
|
||||
var location = new Location(lat, lon);
|
||||
TextBlock label;
|
||||
|
||||
if (childIndex < Children.Count)
|
||||
|
|
@ -273,13 +272,17 @@ namespace MapControl
|
|||
{
|
||||
transformGroup.Children.Add(new TranslateTransform());
|
||||
transformGroup.Children.Add(ParentMap.RotateTransform);
|
||||
transformGroup.Children.Add(new TranslateTransform());
|
||||
}
|
||||
|
||||
var translateTransform = (TranslateTransform)transformGroup.Children[0];
|
||||
translateTransform.X = StrokeThickness / 2d + 2d;
|
||||
translateTransform.Y = -label.DesiredSize.Height / 2d;
|
||||
|
||||
MapPanel.SetLocation(label, location);
|
||||
var viewportPosition = ParentMap.LocationToViewportPoint(new Location(lat, lon));
|
||||
translateTransform = (TranslateTransform)transformGroup.Children[2];
|
||||
translateTransform.X = viewportPosition.X;
|
||||
translateTransform.Y = viewportPosition.Y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,6 +151,23 @@ namespace MapControl
|
|||
|
||||
if (parentMap != null && location != null)
|
||||
{
|
||||
var longitude = Location.NormalizeLongitude(location.Longitude);
|
||||
var centerDistance = longitude - parentMap.Center.Longitude;
|
||||
|
||||
if (centerDistance > 180d)
|
||||
{
|
||||
longitude -= 360d;
|
||||
}
|
||||
else if (centerDistance < -180d)
|
||||
{
|
||||
longitude += 360d;
|
||||
}
|
||||
|
||||
if (location.Longitude != longitude) // keep viewport position near map center
|
||||
{
|
||||
location = new Location(location.Latitude, longitude);
|
||||
}
|
||||
|
||||
viewportPosition = parentMap.LocationToViewportPoint(location);
|
||||
element.SetValue(ViewportPositionProperty, viewportPosition);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@ namespace MapControl
|
|||
{
|
||||
internal partial class TileContainer : Panel
|
||||
{
|
||||
private Matrix GetViewportTransformMatrix(Matrix transform)
|
||||
private Matrix GetViewportTransformMatrix(double scale, double offsetX, double offsetY)
|
||||
{
|
||||
var transform = new Matrix(scale, 0d, 0d, -scale, offsetX, offsetY);
|
||||
|
||||
return transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ namespace MapControl
|
|||
{
|
||||
internal partial class TileContainer : ContainerVisual
|
||||
{
|
||||
private Matrix GetViewportTransformMatrix(Matrix transform)
|
||||
private Matrix GetViewportTransformMatrix(double scale, double offsetX, double offsetY)
|
||||
{
|
||||
var transform = new Matrix(scale, 0d, 0d, -scale, offsetX, offsetY);
|
||||
|
||||
transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
|
||||
|
||||
return transform;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace MapControl
|
|||
tileLayerOffset.X = transformOffsetX - 180d * scale;
|
||||
tileLayerOffset.Y = transformOffsetY - 180d * scale;
|
||||
|
||||
ViewportTransform.Matrix = GetViewportTransformMatrix(new Matrix(scale, 0d, 0d, -scale, transformOffsetX, transformOffsetY));
|
||||
ViewportTransform.Matrix = GetViewportTransformMatrix(scale, transformOffsetX, transformOffsetY);
|
||||
|
||||
if (Math.Sign(mapOrigin.X) != Math.Sign(oldMapOriginX) && Math.Abs(mapOrigin.X) > 90d)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace MapControl
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (!tileSource.UriFormat.StartsWith("file:")) // always load local image files asynchronously
|
||||
else if (!tileSource.UriFormat.StartsWith("file:")) // load local image files asynchronously, without caching
|
||||
{
|
||||
if (Cache == null || string.IsNullOrWhiteSpace(sourceName))
|
||||
{
|
||||
|
|
@ -183,7 +183,7 @@ namespace MapControl
|
|||
|
||||
if (uri != null)
|
||||
{
|
||||
if (uri.Scheme == "file")
|
||||
if (uri.Scheme == "file") // create from FileStream as creating from URI leaves the file open
|
||||
{
|
||||
image = CreateImage(uri.AbsolutePath);
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ namespace MapControl
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(path, FileMode.Open))
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
image = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace MapControl
|
|||
|
||||
public TileLayer()
|
||||
{
|
||||
MinZoomLevel = 1;
|
||||
MinZoomLevel = 0;
|
||||
MaxZoomLevel = 18;
|
||||
MaxParallelDownloads = 8;
|
||||
LoadLowerZoomLevels = true;
|
||||
|
|
|
|||
|
|
@ -145,6 +145,11 @@ namespace MapControl
|
|||
|
||||
private Uri GetQuadKeyUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
if (zoomLevel < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var key = new StringBuilder { Length = zoomLevel };
|
||||
|
||||
for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 7 KiB |
191
SampleApps/Common/ViewModel.cs
Normal file
191
SampleApps/Common/ViewModel.cs
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
#if NETFX_CORE
|
||||
using Windows.UI.Xaml;
|
||||
#else
|
||||
using System.Windows.Threading;
|
||||
#endif
|
||||
using MapControl;
|
||||
|
||||
namespace ViewModel
|
||||
{
|
||||
public class VmBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class VmPoint : VmBase
|
||||
{
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private Location location;
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class VmPolyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class ViewModel : VmBase
|
||||
{
|
||||
public ObservableCollection<VmPoint> Points { get; set; }
|
||||
public ObservableCollection<VmPoint> Pushpins { get; set; }
|
||||
public ObservableCollection<VmPolyline> Polylines { get; set; }
|
||||
|
||||
private Location mapCenter;
|
||||
public Location MapCenter
|
||||
{
|
||||
get { return mapCenter; }
|
||||
set
|
||||
{
|
||||
mapCenter = value;
|
||||
OnPropertyChanged("MapCenter");
|
||||
}
|
||||
}
|
||||
|
||||
public ViewModel()
|
||||
{
|
||||
MapCenter = new Location(53.5, 8.2);
|
||||
|
||||
Points = new ObservableCollection<VmPoint>();
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
Points.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Moving",
|
||||
Location = new Location(53.5, 8.25)
|
||||
});
|
||||
|
||||
Pushpins = new ObservableCollection<VmPoint>();
|
||||
Pushpins.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
Pushpins.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
Pushpins.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
Pushpins.Add(
|
||||
new VmPoint
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
//for (double lon = -720; lon <= 720; lon += 15)
|
||||
//{
|
||||
// var lat = lon / 10;
|
||||
// Pushpins.Add(
|
||||
// new VmPoint
|
||||
// {
|
||||
// Name = string.Format("{0:00.0}°, {1:000}°", lat, lon),
|
||||
// Location = new Location(lat, lon)
|
||||
// });
|
||||
//}
|
||||
|
||||
Polylines = new ObservableCollection<VmPolyline>();
|
||||
Polylines.Add(
|
||||
new VmPolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
||||
});
|
||||
Polylines.Add(
|
||||
new VmPolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
||||
});
|
||||
|
||||
var timer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(0.1)
|
||||
};
|
||||
|
||||
timer.Tick += (sender, e) =>
|
||||
{
|
||||
var p = Points.Last();
|
||||
p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002);
|
||||
|
||||
if (p.Location.Latitude > 54d)
|
||||
{
|
||||
p.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
}
|
||||
};
|
||||
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Silverlight"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Silverlight"
|
||||
xmlns:vm="clr-namespace:ViewModel"
|
||||
xmlns:local="clr-namespace:SilverlightApplication"
|
||||
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
|
||||
<UserControl.Resources>
|
||||
|
|
@ -93,32 +94,32 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<local:SampleItemCollection x:Key="Polylines"/>
|
||||
<local:SampleItemCollection x:Key="Points"/>
|
||||
<local:SampleItemCollection x:Key="Pushpins"/>
|
||||
</UserControl.Resources>
|
||||
<UserControl.DataContext>
|
||||
<vm:ViewModel/>
|
||||
</UserControl.DataContext>
|
||||
<Grid x:Name="LayoutRoot" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<map:Map x:Name="map" Center="53.5,8.2" MinZoomLevel="2" MaxZoomLevel="18" ZoomLevel="11"
|
||||
<map:Map x:Name="map" Center="{Binding MapCenter}" MinZoomLevel="2" MaxZoomLevel="18" ZoomLevel="11"
|
||||
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave">
|
||||
<map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750"
|
||||
Source="10_535_330.jpg" Opacity="0.5"/>
|
||||
<map:MapGraticule Opacity="0.6"/>
|
||||
|
||||
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemTemplate="{StaticResource PolylineItemTemplate}"/>
|
||||
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Points}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Points}"
|
||||
ItemContainerStyle="{StaticResource PointItemStyle}"
|
||||
SelectionMode="Extended"/>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
||||
|
||||
<Path map:MapPanel.Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00">
|
||||
|
|
|
|||
|
|
@ -1,118 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using MapControl;
|
||||
|
||||
namespace SilverlightApplication
|
||||
{
|
||||
public partial class MainPage : UserControl
|
||||
{
|
||||
private SamplePoint movingPoint = new SamplePoint
|
||||
{
|
||||
Name = "Moving",
|
||||
Location = new Location(53.5, 8.25)
|
||||
};
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
tileLayerComboBox.SelectedIndex = 0;
|
||||
|
||||
var polylines = (ICollection<object>)Resources["Polylines"];
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
||||
});
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
||||
});
|
||||
|
||||
var points = (ICollection<object>)Resources["Points"];
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
points.Add(movingPoint);
|
||||
|
||||
var pushpins = (ICollection<object>)Resources["Pushpins"];
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
|
||||
timer.Tick += MovePoint;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void MovePoint(object sender, EventArgs e)
|
||||
{
|
||||
movingPoint.Location = new Location(movingPoint.Location.Latitude + 0.001, movingPoint.Location.Longitude + 0.002);
|
||||
|
||||
if (movingPoint.Location.Latitude > 54d)
|
||||
{
|
||||
movingPoint.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMouseLeave(object sender, MouseEventArgs e)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using MapControl;
|
||||
|
||||
namespace SilverlightApplication
|
||||
{
|
||||
public class SamplePoint : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
private Location location;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SamplePolyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class SampleItemCollection : ObservableCollection<object>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -73,6 +73,9 @@
|
|||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Common\ViewModel.cs">
|
||||
<Link>ViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -80,7 +83,6 @@
|
|||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SampleItems.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
|
|
@ -108,7 +110,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="10_535_330.jpg" />
|
||||
<Resource Include="..\Common\10_535_330.jpg">
|
||||
<Link>10_535_330.jpg</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 7 KiB |
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:map="using:MapControl"
|
||||
xmlns:vm="using:ViewModel"
|
||||
xmlns:local="using:StoreApplication"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
|
|
@ -114,34 +115,31 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<local:SampleItemCollection x:Key="Polylines"/>
|
||||
<local:SampleItemCollection x:Key="Points"/>
|
||||
<local:SampleItemCollection x:Key="Pushpins"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<vm:ViewModel/>
|
||||
</Page.DataContext>
|
||||
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<map:Map x:Name="map" MinZoomLevel="2" MaxZoomLevel="18" ZoomLevel="11" Foreground="Black">
|
||||
<map:MapBase.Center>
|
||||
<map:Location Latitude="53.5" Longitude="8.2"/>
|
||||
</map:MapBase.Center>
|
||||
<map:Map x:Name="map" MinZoomLevel="2" Center="{Binding MapCenter}" MaxZoomLevel="18" ZoomLevel="11" Foreground="Black">
|
||||
<map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750"
|
||||
Source="10_535_330.jpg" Opacity="0.5"/>
|
||||
<map:MapGraticule Opacity="0.6"/>
|
||||
|
||||
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemTemplate="{StaticResource PolylineItemTemplate}"/>
|
||||
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Points}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Points}"
|
||||
ItemContainerStyle="{StaticResource PointItemStyle}"
|
||||
SelectionMode="Extended"/>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
||||
|
||||
<Path Stroke="Blue" StrokeThickness="3">
|
||||
|
|
|
|||
|
|
@ -1,121 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MapControl;
|
||||
using MapControl;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace StoreApplication
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
private SamplePoint movingPoint = new SamplePoint
|
||||
{
|
||||
Name = "Moving",
|
||||
Location = new Location(53.5, 8.25)
|
||||
};
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
tileLayerComboBox.SelectedIndex = 0;
|
||||
|
||||
var polylines = (ICollection<object>)Resources["Polylines"];
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
||||
});
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
||||
});
|
||||
|
||||
var points = (ICollection<object>)Resources["Points"];
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
points.Add(movingPoint);
|
||||
|
||||
var pushpins = (ICollection<object>)Resources["Pushpins"];
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
|
||||
timer.Tick += MovePoint;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void MovePoint(object sender, object e)
|
||||
{
|
||||
movingPoint.Location = new Location(movingPoint.Location.Latitude + 0.001, movingPoint.Location.Longitude + 0.002);
|
||||
|
||||
if (movingPoint.Location.Latitude > 54d)
|
||||
{
|
||||
movingPoint.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using MapControl;
|
||||
|
||||
namespace StoreApplication
|
||||
{
|
||||
public class SamplePoint : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
private Location location;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SamplePolyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class SampleItemCollection : ObservableCollection<object>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Common\ViewModel.cs">
|
||||
<Link>ViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
@ -45,7 +48,6 @@
|
|||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SampleItems.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
|
|
@ -53,7 +55,9 @@
|
|||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="10_535_330.jpg" />
|
||||
<Content Include="..\Common\10_535_330.jpg">
|
||||
<Link>10_535_330.jpg</Link>
|
||||
</Content>
|
||||
<Content Include="Assets\Logo.png" />
|
||||
<Content Include="Assets\SmallLogo.png" />
|
||||
<Content Include="Assets\SplashScreen.png" />
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 7 KiB |
|
|
@ -8,7 +8,7 @@
|
|||
<applicationSettings>
|
||||
<WpfApplication.Properties.Settings>
|
||||
<setting name="TileCache" serializeAs="String">
|
||||
<value />
|
||||
<value>ImageFileCache</value>
|
||||
</setting>
|
||||
</WpfApplication.Properties.Settings>
|
||||
</applicationSettings>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
<Window x:Class="WpfApplication.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
|
||||
xmlns:local="clr-namespace:WpfApplication"
|
||||
Title="XAML MapControl - WPF Test Application" Height="600" Width="800">
|
||||
<Window
|
||||
x:Class="WpfApplication.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
|
||||
xmlns:vm="clr-namespace:ViewModel"
|
||||
xmlns:local="clr-namespace:WpfApplication"
|
||||
Title="XAML MapControl - WPF Test Application" Height="600" Width="800"
|
||||
Stylus.IsPressAndHoldEnabled="False">
|
||||
<Window.Resources>
|
||||
<map:TileLayerCollection x:Key="TileLayers">
|
||||
<!--<map:TileLayer SourceName="OSM Local" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
|
||||
<local:ImageTileSource UriFormat="file:///C:/ProgramData/MapControl/TileCache/OpenStreetMap/{z}/{x}/{y}.png"/>
|
||||
</map:TileLayer>-->
|
||||
<map:TileLayer SourceName="OpenStreetMap" Description="© {y} OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
||||
<map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA"
|
||||
|
|
@ -25,7 +31,7 @@
|
|||
map content without using their APIs (i.e. Google Maps API or Bing Maps API).
|
||||
Hence the declarations shown below are for demonstration purpose only. -->
|
||||
|
||||
<!--<map:TileLayer SourceName="Google Maps" Description="Google Maps - © {y} Google"
|
||||
<map:TileLayer SourceName="Google Maps" Description="Google Maps - © {y} Google"
|
||||
TileSource="http://mt{i}.google.com/vt/x={x}&y={y}&z={z}" MaxZoomLevel="20"/>
|
||||
<map:TileLayer SourceName="Google Images" Description="Google Maps - © {y} Google" Background="#FF3F3F3F" Foreground="White"
|
||||
TileSource="http://khm{i}.google.com/kh/v=135&x={x}&y={y}&z={z}" MaxZoomLevel="20"/>
|
||||
|
|
@ -34,7 +40,7 @@
|
|||
<map:TileLayer SourceName="Bing Images" Description="Bing Maps - © {y} Microsoft Corporation" Background="#FF3F3F3F" Foreground="White"
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/a{q}.jpeg?g=0" MaxZoomLevel="20"/>
|
||||
<map:TileLayer SourceName="Bing Hybrid" Description="Bing Maps - © {y} Microsoft Corporation" Background="#FF3F3F3F" Foreground="White"
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&stl=h" MaxZoomLevel="20"/>-->
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&stl=h" MaxZoomLevel="20"/>
|
||||
|
||||
<!-- The following TileLayer uses an ImageTileSource, which bypasses caching of map tile images -->
|
||||
<!--<map:TileLayer SourceName="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
|
||||
|
|
@ -109,6 +115,7 @@
|
|||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
|
||||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
|
|
@ -129,22 +136,23 @@
|
|||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="OrangeRed"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<local:SampleItemCollection x:Key="Polylines"/>
|
||||
<local:SampleItemCollection x:Key="Points"/>
|
||||
<local:SampleItemCollection x:Key="Pushpins"/>
|
||||
</Window.Resources>
|
||||
<Window.DataContext>
|
||||
<vm:ViewModel/>
|
||||
</Window.DataContext>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<map:Map x:Name="map" Margin="2" Center="53.5,8.2" ZoomLevel="11" MaxZoomLevel="20"
|
||||
<map:Map x:Name="map" Margin="2" Center="{Binding MapCenter}" ZoomLevel="11" MaxZoomLevel="20"
|
||||
TileLayer="{Binding Source={StaticResource TileLayersViewSource}, Path=CurrentItem}"
|
||||
MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown"
|
||||
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"
|
||||
|
|
@ -163,17 +171,17 @@
|
|||
<map:MapScale Margin="4" Opacity="0.8"/>
|
||||
|
||||
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemTemplate="{StaticResource PolylineItemTemplate}"/>
|
||||
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
<!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Points}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Points}"
|
||||
ItemContainerStyle="{StaticResource PointItemStyle}"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
SelectionMode="Extended"/>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"
|
||||
IsSynchronizedWithCurrentItem="True"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.Caching;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Caching;
|
||||
using MapControl;
|
||||
|
||||
|
|
@ -13,12 +11,6 @@ namespace WpfApplication
|
|||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private SamplePoint movingPoint = new SamplePoint
|
||||
{
|
||||
Name = "Moving",
|
||||
Location = new Location(53.5, 8.25)
|
||||
};
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
switch (Properties.Settings.Default.TileCache)
|
||||
|
|
@ -37,98 +29,6 @@ namespace WpfApplication
|
|||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var polylines = (ICollection<object>)Resources["Polylines"];
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
||||
});
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
||||
});
|
||||
|
||||
var points = (ICollection<object>)Resources["Points"];
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
points.Add(movingPoint);
|
||||
|
||||
var pushpins = (ICollection<object>)Resources["Pushpins"];
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) };
|
||||
timer.Tick += MovePoint;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void MovePoint(object sender, EventArgs e)
|
||||
{
|
||||
movingPoint.Location = new Location(movingPoint.Location.Latitude + 0.001, movingPoint.Location.Longitude + 0.002);
|
||||
|
||||
if (movingPoint.Location.Latitude > 54d)
|
||||
{
|
||||
movingPoint.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
|
|
@ -171,6 +71,13 @@ namespace WpfApplication
|
|||
e.TranslationBehavior.DesiredDeceleration = 0.001;
|
||||
}
|
||||
|
||||
private void MapItemTouchDown(object sender, TouchEventArgs e)
|
||||
{
|
||||
var mapItem = (MapItem)sender;
|
||||
mapItem.IsSelected = !mapItem.IsSelected;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void SeamarksClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var seamarks = (TileLayer)Resources["SeamarksTileLayer"];
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.8.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0")]
|
||||
[assembly: AssemblyVersion("1.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.9.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34003
|
||||
// Runtime Version:4.0.30319.18408
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
|
@ -25,7 +25,7 @@ namespace WpfApplication.Properties {
|
|||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("ImageFileCache")]
|
||||
public string TileCache {
|
||||
get {
|
||||
return ((string)(this["TileCache"]));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="TileCache" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
<Value Profile="(Default)">ImageFileCache</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using MapControl;
|
||||
|
||||
namespace WpfApplication
|
||||
{
|
||||
public class SamplePoint : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
private Location location;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SamplePolyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class SampleItemCollection : ObservableCollection<object>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="SampleItems.cs" />
|
||||
<Compile Include="..\Common\ViewModel.cs">
|
||||
<Link>ViewModel.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ImageTileSource.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
|
@ -97,7 +100,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="10_535_330.jpg" />
|
||||
<Resource Include="..\Common\10_535_330.jpg">
|
||||
<Link>10_535_330.jpg</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
Loading…
Reference in a new issue