diff --git a/MapControl/Map.cs b/MapControl/Map.cs index 65a38688..43255cb8 100644 --- a/MapControl/Map.cs +++ b/MapControl/Map.cs @@ -108,6 +108,18 @@ namespace MapControl AddVisualChild(tileContainer); TileLayers = new TileLayerCollection(); SetValue(ParentMapProperty, this); + + Loaded += (o, e) => + { + if (MainTileLayer == null) + { + MainTileLayer = new TileLayer + { + Description = "© {y} OpenStreetMap Contributors, CC-BY-SA", + TileSource = new OpenStreetMapTileSource { UriFormat = "http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png" } + }; + } + }; } /// diff --git a/TestApplication/MainWindow.xaml b/TestApplication/MainWindow.xaml index 14f6e66c..2d1078b1 100644 --- a/TestApplication/MainWindow.xaml +++ b/TestApplication/MainWindow.xaml @@ -9,20 +9,13 @@ Name="Seamarks" Description="© {y} OpenSeaMap Contributors, CC-BY-SA" TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" IsCached="False" MinZoomLevel="10" MaxZoomLevel="18"/> - - - - - - - @@ -154,10 +93,15 @@ ManipulationInertiaStarting="MapManipulationInertiaStarting" MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"> - + - + + N 53° 30' E 8° 12' diff --git a/TestApplication/MainWindow.xaml.cs b/TestApplication/MainWindow.xaml.cs index d87c4c76..0733b060 100644 --- a/TestApplication/MainWindow.xaml.cs +++ b/TestApplication/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; @@ -14,87 +15,80 @@ namespace MapControlTestApp { InitializeComponent(); - SampleItemCollection items = (SampleItemCollection)Resources["SampleItems"]; - items.Add( + ICollection polylines = (ICollection)Resources["Polylines"]; + polylines.Add( new SamplePolyline { - Name = "WHV - Eckwarderhörne", 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") }); - items.Add( - new SamplePolygon + polylines.Add( + new SamplePolyline { - Name = "JadeWeserPort", - 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") + 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") }); - items.Add( - new SamplePushpin - { - Name = "WHV - Eckwarderhörne", - Location = new Location(53.5495, 8.1877) - }); - items.Add( - new SamplePushpin - { - Name = "JadeWeserPort", - Location = new Location(53.5914, 8.14) - }); - items.Add( - new SamplePushpin - { - Name = "Kurhaus Dangast", - Location = new Location(53.447, 8.1114) - }); - items.Add( - new SamplePushpin - { - Name = "Eckwarderhörne", - Location = new Location(53.5207, 8.2323) - }); - items.Add( + + ICollection points = (ICollection)Resources["Points"]; + points.Add( new SamplePoint { Name = "Steinbake Leitdamm", Location = new Location(53.51217, 8.16603) }); - items.Add( + points.Add( new SamplePoint { Name = "Buhne 2", Location = new Location(53.50926, 8.15815) }); - items.Add( + points.Add( new SamplePoint { Name = "Buhne 4", Location = new Location(53.50468, 8.15343) }); - items.Add( + points.Add( new SamplePoint { Name = "Buhne 6", Location = new Location(53.50092, 8.15267) }); - items.Add( + points.Add( new SamplePoint { Name = "Buhne 8", Location = new Location(53.49871, 8.15321) }); - items.Add( + points.Add( new SamplePoint { Name = "Buhne 10", Location = new Location(53.49350, 8.15563) }); - items.Add( - new SampleShape + + ICollection pushpins = (ICollection)Resources["Pushpins"]; + pushpins.Add( + new SamplePoint { - Name = "N 53° 30' E 8° 12'", - Location = new Location(53.5, 8.2), - RadiusX = 200d, // meters - RadiusY = 300d, // meters - Rotation = 30d + 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) }); } diff --git a/TestApplication/SampleItems.cs b/TestApplication/SampleItems.cs index acf41317..3193109d 100644 --- a/TestApplication/SampleItems.cs +++ b/TestApplication/SampleItems.cs @@ -1,71 +1,20 @@ -using System; -using System.Collections.ObjectModel; -using System.Windows; -using System.Windows.Controls; +using System.Collections.ObjectModel; using MapControl; namespace MapControlTestApp { - class SampleItem + class SamplePoint { public string Name { get; set; } - } - - class SamplePoint : SampleItem - { public Location Location { get; set; } } - class SamplePushpin : SamplePoint - { - } - - class SampleShape : SamplePoint - { - public double RadiusX { get; set; } - public double RadiusY { get; set; } - public double Rotation { get; set; } - } - - class SamplePolyline : SampleItem + class SamplePolyline { public LocationCollection Locations { get; set; } } - class SamplePolygon : SampleItem + class SampleItemCollection : ObservableCollection { - public LocationCollection Locations { get; set; } - } - - class SampleItemCollection : ObservableCollection - { - } - - class SampleItemStyleSelector : StyleSelector - { - public override Style SelectStyle(object item, DependencyObject container) - { - if (item is SamplePolyline) - { - return Application.Current.Windows[0].Resources["SamplePolylineItemStyle"] as Style; - } - - if (item is SamplePolygon) - { - return Application.Current.Windows[0].Resources["SamplePolygonItemStyle"] as Style; - } - - if (item is SampleShape) - { - return Application.Current.Windows[0].Resources["SampleShapeItemStyle"] as Style; - } - - if (item is SamplePushpin) - { - return Application.Current.Windows[0].Resources["SamplePushpinItemStyle"] as Style; - } - - return Application.Current.Windows[0].Resources["SamplePointItemStyle"] as Style; - } } }