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:
ClemensF 2013-11-17 16:52:03 +01:00
parent 9f4ab0f3e3
commit 5eafa751f8
37 changed files with 391 additions and 571 deletions

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -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() protected override void OnViewportChanged()
{ {
base.OnViewportChanged(); base.OnViewportChanged();
@ -551,8 +572,14 @@ namespace MapControl
internalPropertyChange = false; 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 maxLatitude = mapTransform.MaxLatitude + latitudeEpsilon;
var latitude = Math.Min(Math.Max(location.Latitude, -maxLatitude), maxLatitude); var latitude = Math.Min(Math.Max(location.Latitude, -maxLatitude), maxLatitude);
var longitude = Location.NormalizeLongitude(location.Longitude); var longitude = Location.NormalizeLongitude(location.Longitude);
@ -567,9 +594,9 @@ namespace MapControl
return false; 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); InternalSetValue(property, center);
} }
@ -579,7 +606,7 @@ namespace MapControl
{ {
if (!internalPropertyChange) if (!internalPropertyChange)
{ {
CoerceCenterProperty(CenterProperty, center); CoerceCenterProperty(CenterProperty, ref center);
ResetTransformOrigin(); ResetTransformOrigin();
UpdateTransform(); UpdateTransform();
@ -595,9 +622,9 @@ namespace MapControl
{ {
if (!internalPropertyChange) 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) if (centerAnimation != null)
{ {
@ -652,9 +679,11 @@ namespace MapControl
if (coercedValue != minZoomLevel) if (coercedValue != minZoomLevel)
{ {
InternalSetValue(MinZoomLevelProperty, coercedValue); minZoomLevel = coercedValue;
InternalSetValue(MinZoomLevelProperty, minZoomLevel);
} }
else if (ZoomLevel < minZoomLevel)
if (ZoomLevel < minZoomLevel)
{ {
ZoomLevel = minZoomLevel; ZoomLevel = minZoomLevel;
} }
@ -666,32 +695,32 @@ namespace MapControl
if (coercedValue != maxZoomLevel) if (coercedValue != maxZoomLevel)
{ {
InternalSetValue(MaxZoomLevelProperty, coercedValue); maxZoomLevel = coercedValue;
InternalSetValue(MaxZoomLevelProperty, maxZoomLevel);
} }
else if (ZoomLevel > maxZoomLevel)
if (ZoomLevel > maxZoomLevel)
{ {
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); var coercedValue = Math.Min(Math.Max(zoomLevel, MinZoomLevel), MaxZoomLevel);
if (coercedValue != zoomLevel) if (coercedValue != zoomLevel)
{ {
InternalSetValue(property, coercedValue); zoomLevel = coercedValue;
return true; InternalSetValue(property, zoomLevel);
} }
return false;
} }
private void ZoomLevelPropertyChanged(double zoomLevel) private void ZoomLevelPropertyChanged(double zoomLevel)
{ {
if (!internalPropertyChange && if (!internalPropertyChange)
!CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel))
{ {
CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel);
UpdateTransform(); UpdateTransform();
if (zoomLevelAnimation == null) if (zoomLevelAnimation == null)
@ -703,25 +732,28 @@ namespace MapControl
private void TargetZoomLevelPropertyChanged(double targetZoomLevel) private void TargetZoomLevelPropertyChanged(double targetZoomLevel)
{ {
if (!internalPropertyChange && if (!internalPropertyChange)
!CoerceZoomLevelProperty(TargetZoomLevelProperty, ref targetZoomLevel) &&
targetZoomLevel != ZoomLevel)
{ {
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) private void CoerceHeadingProperty(DependencyProperty property, ref double heading)
{ {
var coercedValue = (heading >= -180d && heading <= 360d) ? var coercedValue = (heading >= -180d && heading <= 360d) ? heading : (((heading % 360d) + 360d) % 360d);
heading : (((heading % 360d) + 360d) % 360d);
if (coercedValue != heading) 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)); 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); InternalSetValue(CenterProperty, center);

View file

@ -226,7 +226,6 @@ namespace MapControl
{ {
for (var lon = labelsStart.Longitude; lon <= end.Longitude; lon += spacing) for (var lon = labelsStart.Longitude; lon <= end.Longitude; lon += spacing)
{ {
var location = new Location(lat, lon);
TextBlock label; TextBlock label;
if (childIndex < Children.Count) if (childIndex < Children.Count)
@ -273,13 +272,17 @@ namespace MapControl
{ {
transformGroup.Children.Add(new TranslateTransform()); transformGroup.Children.Add(new TranslateTransform());
transformGroup.Children.Add(ParentMap.RotateTransform); transformGroup.Children.Add(ParentMap.RotateTransform);
transformGroup.Children.Add(new TranslateTransform());
} }
var translateTransform = (TranslateTransform)transformGroup.Children[0]; var translateTransform = (TranslateTransform)transformGroup.Children[0];
translateTransform.X = StrokeThickness / 2d + 2d; translateTransform.X = StrokeThickness / 2d + 2d;
translateTransform.Y = -label.DesiredSize.Height / 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;
} }
} }

View file

@ -151,6 +151,23 @@ namespace MapControl
if (parentMap != null && location != null) 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); viewportPosition = parentMap.LocationToViewportPoint(location);
element.SetValue(ViewportPositionProperty, viewportPosition); element.SetValue(ViewportPositionProperty, viewportPosition);
} }

View file

@ -15,8 +15,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -17,8 +17,10 @@ namespace MapControl
{ {
internal partial class TileContainer : Panel 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); return transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
} }

View file

@ -9,8 +9,10 @@ namespace MapControl
{ {
internal partial class TileContainer : ContainerVisual 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); transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
return transform; return transform;

View file

@ -101,7 +101,7 @@ namespace MapControl
tileLayerOffset.X = transformOffsetX - 180d * scale; tileLayerOffset.X = transformOffsetX - 180d * scale;
tileLayerOffset.Y = transformOffsetY - 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) if (Math.Sign(mapOrigin.X) != Math.Sign(oldMapOriginX) && Math.Abs(mapOrigin.X) > 90d)
{ {

View file

@ -104,7 +104,7 @@ namespace MapControl
return; 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)) if (Cache == null || string.IsNullOrWhiteSpace(sourceName))
{ {
@ -183,7 +183,7 @@ namespace MapControl
if (uri != null) 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); image = CreateImage(uri.AbsolutePath);
} }
@ -256,7 +256,7 @@ namespace MapControl
{ {
try 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); image = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
} }

View file

@ -48,7 +48,7 @@ namespace MapControl
public TileLayer() public TileLayer()
{ {
MinZoomLevel = 1; MinZoomLevel = 0;
MaxZoomLevel = 18; MaxZoomLevel = 18;
MaxParallelDownloads = 8; MaxParallelDownloads = 8;
LoadLowerZoomLevels = true; LoadLowerZoomLevels = true;

View file

@ -145,6 +145,11 @@ namespace MapControl
private Uri GetQuadKeyUri(int x, int y, int zoomLevel) private Uri GetQuadKeyUri(int x, int y, int zoomLevel)
{ {
if (zoomLevel < 1)
{
return null;
}
var key = new StringBuilder { Length = zoomLevel }; var key = new StringBuilder { Length = zoomLevel };
for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2) for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2)

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 7 KiB

View 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();
}
}
}

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -4,8 +4,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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:sys="clr-namespace:System;assembly=mscorlib"
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Silverlight"
xmlns:vm="clr-namespace:ViewModel"
xmlns:local="clr-namespace:SilverlightApplication" xmlns:local="clr-namespace:SilverlightApplication"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources> <UserControl.Resources>
@ -93,32 +94,32 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<local:SampleItemCollection x:Key="Polylines"/>
<local:SampleItemCollection x:Key="Points"/>
<local:SampleItemCollection x:Key="Pushpins"/>
</UserControl.Resources> </UserControl.Resources>
<UserControl.DataContext>
<vm:ViewModel/>
</UserControl.DataContext>
<Grid x:Name="LayoutRoot" Background="White"> <Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </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"> MouseMove="MapMouseMove" MouseLeave="MapMouseLeave">
<map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750" <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"/> Source="10_535_330.jpg" Opacity="0.5"/>
<map:MapGraticule Opacity="0.6"/> <map:MapGraticule Opacity="0.6"/>
<!-- use ItemTemplate or ItemContainerStyle alternatively --> <!-- use ItemTemplate or ItemContainerStyle alternatively -->
<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemTemplate="{StaticResource PolylineItemTemplate}"/> ItemTemplate="{StaticResource PolylineItemTemplate}"/>
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>--> ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
<map:MapItemsControl ItemsSource="{StaticResource Points}" <map:MapItemsControl ItemsSource="{Binding Points}"
ItemContainerStyle="{StaticResource PointItemStyle}" ItemContainerStyle="{StaticResource PointItemStyle}"
SelectionMode="Extended"/> SelectionMode="Extended"/>
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}" <map:MapItemsControl ItemsSource="{Binding Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}"/> ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
<Path map:MapPanel.Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00"> <Path map:MapPanel.Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00">

View file

@ -1,118 +1,17 @@
using System; using System.Globalization;
using System.Collections.Generic;
using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading;
using MapControl; using MapControl;
namespace SilverlightApplication namespace SilverlightApplication
{ {
public partial class MainPage : UserControl public partial class MainPage : UserControl
{ {
private SamplePoint movingPoint = new SamplePoint
{
Name = "Moving",
Location = new Location(53.5, 8.25)
};
public MainPage() public MainPage()
{ {
InitializeComponent(); InitializeComponent();
tileLayerComboBox.SelectedIndex = 0; 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) private void MapMouseLeave(object sender, MouseEventArgs e)

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -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>
{
}
}

View file

@ -73,6 +73,9 @@
<Reference Include="System.Windows.Browser" /> <Reference Include="System.Windows.Browser" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Common\ViewModel.cs">
<Link>ViewModel.cs</Link>
</Compile>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
@ -80,7 +83,6 @@
<DependentUpon>MainPage.xaml</DependentUpon> <DependentUpon>MainPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleItems.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Include="App.xaml"> <ApplicationDefinition Include="App.xaml">
@ -108,7 +110,9 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="10_535_330.jpg" /> <Resource Include="..\Common\10_535_330.jpg">
<Link>10_535_330.jpg</Link>
</Resource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" /> <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. <!-- 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

View file

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:map="using:MapControl" xmlns:map="using:MapControl"
xmlns:vm="using:ViewModel"
xmlns:local="using:StoreApplication" xmlns:local="using:StoreApplication"
mc:Ignorable="d"> mc:Ignorable="d">
<Page.Resources> <Page.Resources>
@ -114,34 +115,31 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<local:SampleItemCollection x:Key="Polylines"/>
<local:SampleItemCollection x:Key="Points"/>
<local:SampleItemCollection x:Key="Pushpins"/>
</Page.Resources> </Page.Resources>
<Page.DataContext>
<vm:ViewModel/>
</Page.DataContext>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<map:Map x:Name="map" MinZoomLevel="2" MaxZoomLevel="18" ZoomLevel="11" Foreground="Black"> <map:Map x:Name="map" MinZoomLevel="2" Center="{Binding MapCenter}" MaxZoomLevel="18" ZoomLevel="11" Foreground="Black">
<map:MapBase.Center>
<map:Location Latitude="53.5" Longitude="8.2"/>
</map:MapBase.Center>
<map:MapImage x:Name="mapImage" South="53.54031" North="53.74871" West="8.08594" East="8.43750" <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"/> Source="10_535_330.jpg" Opacity="0.5"/>
<map:MapGraticule Opacity="0.6"/> <map:MapGraticule Opacity="0.6"/>
<!-- use ItemTemplate or ItemContainerStyle alternatively --> <!-- use ItemTemplate or ItemContainerStyle alternatively -->
<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemTemplate="{StaticResource PolylineItemTemplate}"/> ItemTemplate="{StaticResource PolylineItemTemplate}"/>
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>--> ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
<map:MapItemsControl ItemsSource="{StaticResource Points}" <map:MapItemsControl ItemsSource="{Binding Points}"
ItemContainerStyle="{StaticResource PointItemStyle}" ItemContainerStyle="{StaticResource PointItemStyle}"
SelectionMode="Extended"/> SelectionMode="Extended"/>
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}" <map:MapItemsControl ItemsSource="{Binding Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}"/> ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
<Path Stroke="Blue" StrokeThickness="3"> <Path Stroke="Blue" StrokeThickness="3">

View file

@ -1,121 +1,16 @@
using System; using MapControl;
using System.Collections.Generic;
using MapControl;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Controls.Primitives;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace StoreApplication 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 public sealed partial class MainPage : Page
{ {
private SamplePoint movingPoint = new SamplePoint
{
Name = "Moving",
Location = new Location(53.5, 8.25)
};
public MainPage() public MainPage()
{ {
this.InitializeComponent(); this.InitializeComponent();
tileLayerComboBox.SelectedIndex = 0; 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) private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -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>
{
}
}

View file

@ -37,6 +37,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Common\ViewModel.cs">
<Link>ViewModel.cs</Link>
</Compile>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
@ -45,7 +48,6 @@
<DependentUpon>MainPage.xaml</DependentUpon> <DependentUpon>MainPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleItems.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AppxManifest Include="Package.appxmanifest"> <AppxManifest Include="Package.appxmanifest">
@ -53,7 +55,9 @@
</AppxManifest> </AppxManifest>
</ItemGroup> </ItemGroup>
<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\Logo.png" />
<Content Include="Assets\SmallLogo.png" /> <Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" /> <Content Include="Assets\SplashScreen.png" />

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

View file

@ -8,7 +8,7 @@
<applicationSettings> <applicationSettings>
<WpfApplication.Properties.Settings> <WpfApplication.Properties.Settings>
<setting name="TileCache" serializeAs="String"> <setting name="TileCache" serializeAs="String">
<value /> <value>ImageFileCache</value>
</setting> </setting>
</WpfApplication.Properties.Settings> </WpfApplication.Properties.Settings>
</applicationSettings> </applicationSettings>

View file

@ -1,11 +1,17 @@
<Window x:Class="WpfApplication.MainWindow" <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Class="WpfApplication.MainWindow"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication" xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
Title="XAML MapControl - WPF Test Application" Height="600" Width="800"> 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> <Window.Resources>
<map:TileLayerCollection x:Key="TileLayers"> <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" <map:TileLayer SourceName="OpenStreetMap" Description="© {y} OpenStreetMap Contributors, CC-BY-SA"
TileSource="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/> TileSource="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA" <map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA"
@ -25,7 +31,7 @@
map content without using their APIs (i.e. Google Maps API or Bing Maps API). 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. --> 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}&amp;y={y}&amp;z={z}" MaxZoomLevel="20"/> TileSource="http://mt{i}.google.com/vt/x={x}&amp;y={y}&amp;z={z}" MaxZoomLevel="20"/>
<map:TileLayer SourceName="Google Images" Description="Google Maps - © {y} Google" Background="#FF3F3F3F" Foreground="White" <map:TileLayer SourceName="Google Images" Description="Google Maps - © {y} Google" Background="#FF3F3F3F" Foreground="White"
TileSource="http://khm{i}.google.com/kh/v=135&amp;x={x}&amp;y={y}&amp;z={z}" MaxZoomLevel="20"/> TileSource="http://khm{i}.google.com/kh/v=135&amp;x={x}&amp;y={y}&amp;z={z}" MaxZoomLevel="20"/>
@ -34,7 +40,7 @@
<map:TileLayer SourceName="Bing Images" Description="Bing Maps - © {y} Microsoft Corporation" Background="#FF3F3F3F" Foreground="White" <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"/> 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" <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&amp;stl=h" MaxZoomLevel="20"/>--> TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&amp;stl=h" MaxZoomLevel="20"/>
<!-- The following TileLayer uses an ImageTileSource, which bypasses caching of map tile images --> <!-- 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"> <!--<map:TileLayer SourceName="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
@ -109,6 +115,7 @@
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
</Style> </Style>
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem"> <Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/> <Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
@ -129,22 +136,23 @@
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="OrangeRed"/> <Setter Property="Foreground" Value="OrangeRed"/>
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<local:SampleItemCollection x:Key="Polylines"/>
<local:SampleItemCollection x:Key="Points"/>
<local:SampleItemCollection x:Key="Pushpins"/>
</Window.Resources> </Window.Resources>
<Window.DataContext>
<vm:ViewModel/>
</Window.DataContext>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </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}" TileLayer="{Binding Source={StaticResource TileLayersViewSource}, Path=CurrentItem}"
MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown" MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown"
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave" MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"
@ -163,17 +171,17 @@
<map:MapScale Margin="4" Opacity="0.8"/> <map:MapScale Margin="4" Opacity="0.8"/>
<!-- use ItemTemplate or ItemContainerStyle alternatively --> <!-- use ItemTemplate or ItemContainerStyle alternatively -->
<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemTemplate="{StaticResource PolylineItemTemplate}"/> ItemTemplate="{StaticResource PolylineItemTemplate}"/>
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}" <!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>--> ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
<map:MapItemsControl ItemsSource="{StaticResource Points}" <map:MapItemsControl ItemsSource="{Binding Points}"
ItemContainerStyle="{StaticResource PointItemStyle}" ItemContainerStyle="{StaticResource PointItemStyle}"
IsSynchronizedWithCurrentItem="True" IsSynchronizedWithCurrentItem="True"
SelectionMode="Extended"/> SelectionMode="Extended"/>
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}" <map:MapItemsControl ItemsSource="{Binding Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}" ItemContainerStyle="{StaticResource PushpinItemStyle}"
IsSynchronizedWithCurrentItem="True"/> IsSynchronizedWithCurrentItem="True"/>

View file

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Runtime.Caching; using System.Runtime.Caching;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading;
using Caching; using Caching;
using MapControl; using MapControl;
@ -13,12 +11,6 @@ namespace WpfApplication
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private SamplePoint movingPoint = new SamplePoint
{
Name = "Moving",
Location = new Location(53.5, 8.25)
};
public MainWindow() public MainWindow()
{ {
switch (Properties.Settings.Default.TileCache) switch (Properties.Settings.Default.TileCache)
@ -37,98 +29,6 @@ namespace WpfApplication
} }
InitializeComponent(); 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) private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
@ -171,6 +71,13 @@ namespace WpfApplication
e.TranslationBehavior.DesiredDeceleration = 0.001; 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) private void SeamarksClick(object sender, RoutedEventArgs e)
{ {
var seamarks = (TileLayer)Resources["SeamarksTileLayer"]; var seamarks = (TileLayer)Resources["SeamarksTileLayer"];

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.8.0")] [assembly: AssemblyVersion("1.9.0")]
[assembly: AssemblyFileVersion("1.8.0")] [assembly: AssemblyFileVersion("1.9.0")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // 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 // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -25,7 +25,7 @@ namespace WpfApplication.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")] [global::System.Configuration.DefaultSettingValueAttribute("ImageFileCache")]
public string TileCache { public string TileCache {
get { get {
return ((string)(this["TileCache"])); return ((string)(this["TileCache"]));

View file

@ -3,7 +3,7 @@
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="TileCache" Type="System.String" Scope="Application"> <Setting Name="TileCache" Type="System.String" Scope="Application">
<Value Profile="(Default)" /> <Value Profile="(Default)">ImageFileCache</Value>
</Setting> </Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View file

@ -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>
{
}
}

View file

@ -49,7 +49,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="SampleItems.cs" /> <Compile Include="..\Common\ViewModel.cs">
<Link>ViewModel.cs</Link>
</Compile>
<Compile Include="ImageTileSource.cs" />
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -97,7 +100,9 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="10_535_330.jpg" /> <Resource Include="..\Common\10_535_330.jpg">
<Link>10_535_330.jpg</Link>
</Resource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.