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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

View file

@ -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">

View file

@ -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)

View file

@ -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)]

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" />
</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.