mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Version 4: Upgrade to VS 2017
This commit is contained in:
parent
2aafe32e00
commit
ec47f225b3
142 changed files with 1828 additions and 18384 deletions
BIN
SampleApps/Shared/10_535_330.jpg
Normal file
BIN
SampleApps/Shared/10_535_330.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7 KiB |
199
SampleApps/Shared/MapLayers.cs
Normal file
199
SampleApps/Shared/MapLayers.cs
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
using MapControl;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
#if NETFX_CORE
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
#else
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
#endif
|
||||
|
||||
namespace ViewModel
|
||||
{
|
||||
public class MapLayers : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private readonly Dictionary<string, UIElement> mapLayers = new Dictionary<string, UIElement>
|
||||
{
|
||||
{
|
||||
"OpenStreetMap",
|
||||
MapTileLayer.OpenStreetMapTileLayer
|
||||
},
|
||||
{
|
||||
"OpenStreetMap German Style",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "OpenStreetMap German",
|
||||
Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png" },
|
||||
MaxZoomLevel = 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"Thunderforest OpenCycleMap",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "Thunderforest OpenCycleMap",
|
||||
Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"Thunderforest Landscape",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "Thunderforest Landscape",
|
||||
Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"Thunderforest Outdoors",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "Thunderforest Outdoors",
|
||||
Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"Thunderforest Transport",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "Thunderforest Transport",
|
||||
Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/transport/{z}/{x}/{y}.png" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"Thunderforest Transport Dark",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "Thunderforest Transport Dark",
|
||||
Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)",
|
||||
TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png" },
|
||||
MapForeground = new SolidColorBrush(Colors.White),
|
||||
MapBackground = new SolidColorBrush(Colors.Black)
|
||||
}
|
||||
},
|
||||
{
|
||||
"Seamarks",
|
||||
new MapTileLayer
|
||||
{
|
||||
SourceName = "OpenSeaMap",
|
||||
TileSource = new TileSource { UriFormat = "http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" },
|
||||
MinZoomLevel = 9,
|
||||
MaxZoomLevel = 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"Bing Maps Road",
|
||||
new BingMapsTileLayer
|
||||
{
|
||||
SourceName = "Bing Maps Road",
|
||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
||||
Mode = BingMapsTileLayer.MapMode.Road,
|
||||
MaxZoomLevel = 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"Bing Maps Aerial",
|
||||
new BingMapsTileLayer
|
||||
{
|
||||
SourceName = "Bing Maps Aerial",
|
||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
||||
Mode = BingMapsTileLayer.MapMode.Aerial,
|
||||
MaxZoomLevel = 19,
|
||||
MapForeground = new SolidColorBrush(Colors.White),
|
||||
MapBackground = new SolidColorBrush(Colors.Black)
|
||||
}
|
||||
},
|
||||
{
|
||||
"Bing Maps Aerial with Labels",
|
||||
new BingMapsTileLayer
|
||||
{
|
||||
SourceName = "Bing Maps Hybrid",
|
||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
||||
Mode = BingMapsTileLayer.MapMode.AerialWithLabels,
|
||||
MaxZoomLevel = 19,
|
||||
MapForeground = new SolidColorBrush(Colors.White),
|
||||
MapBackground = new SolidColorBrush(Colors.Black)
|
||||
}
|
||||
},
|
||||
{
|
||||
"OpenStreetMap WMS",
|
||||
new WmsImageLayer
|
||||
{
|
||||
Description = "OpenStreetMap WMS",
|
||||
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
||||
Layers = "OSM-WMS",
|
||||
MapBackground = new SolidColorBrush(Colors.LightGray)
|
||||
}
|
||||
},
|
||||
{
|
||||
"OpenStreetMap TOPO WMS",
|
||||
new WmsImageLayer
|
||||
{
|
||||
Description = "OpenStreetMap TOPO WMS",
|
||||
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
||||
Layers = "TOPO-OSM-WMS",
|
||||
MapBackground = new SolidColorBrush(Colors.LightGray)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private string currentMapLayerName = "OpenStreetMap";
|
||||
|
||||
public string CurrentMapLayerName
|
||||
{
|
||||
get { return currentMapLayerName; }
|
||||
set
|
||||
{
|
||||
currentMapLayerName = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentMapLayerName)));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentMapLayer)));
|
||||
}
|
||||
}
|
||||
|
||||
public UIElement CurrentMapLayer
|
||||
{
|
||||
get { return mapLayers[currentMapLayerName]; }
|
||||
}
|
||||
|
||||
public UIElement SeamarksLayer
|
||||
{
|
||||
get { return mapLayers["Seamarks"]; }
|
||||
}
|
||||
|
||||
public List<string> MapLayerNames { get; } = new List<string>
|
||||
{
|
||||
"OpenStreetMap",
|
||||
"OpenStreetMap German Style",
|
||||
"Thunderforest OpenCycleMap",
|
||||
//"Thunderforest Landscape",
|
||||
//"Thunderforest Outdoors",
|
||||
//"Thunderforest Transport",
|
||||
//"Thunderforest Transport Dark",
|
||||
"OpenStreetMap WMS",
|
||||
"OpenStreetMap TOPO WMS"
|
||||
};
|
||||
|
||||
public MapLayers()
|
||||
{
|
||||
//BingMapsTileLayer.ApiKey = "...";
|
||||
|
||||
// Bing Maps TileLayers with tile URLs retrieved from the Imagery Metadata Service
|
||||
// (see http://msdn.microsoft.com/en-us/library/ff701716.aspx).
|
||||
// A Bing Maps API Key (see http://msdn.microsoft.com/en-us/library/ff428642.aspx) is required
|
||||
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
||||
|
||||
//MapLayerNames.Add("Bing Maps Road");
|
||||
//MapLayerNames.Add("Bing Maps Aerial");
|
||||
//MapLayerNames.Add("Bing Maps Aerial with Labels");
|
||||
}
|
||||
}
|
||||
}
|
||||
130
SampleApps/Shared/MapViewModel.cs
Normal file
130
SampleApps/Shared/MapViewModel.cs
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
using MapControl;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ViewModel
|
||||
{
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void RaisePropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public class PointItem : ViewModelBase
|
||||
{
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
RaisePropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
private Location location;
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
RaisePropertyChanged(nameof(Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Polyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class MapViewModel : ViewModelBase
|
||||
{
|
||||
private Location mapCenter = new Location(53.5, 8.2);
|
||||
public Location MapCenter
|
||||
{
|
||||
get { return mapCenter; }
|
||||
set
|
||||
{
|
||||
mapCenter = value;
|
||||
RaisePropertyChanged(nameof(MapCenter));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<PointItem> Points { get; } = new ObservableCollection<PointItem>();
|
||||
public ObservableCollection<PointItem> Pushpins { get; } = new ObservableCollection<PointItem>();
|
||||
public ObservableCollection<Polyline> Polylines { get; } = new ObservableCollection<Polyline>();
|
||||
|
||||
public MapLayers MapLayers { get; } = new MapLayers();
|
||||
|
||||
public MapViewModel()
|
||||
{
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
|
||||
Pushpins.Add(new PointItem
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
Pushpins.Add(new PointItem
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
Pushpins.Add(new PointItem
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
Pushpins.Add(new PointItem
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
Polylines.Add(new Polyline
|
||||
{
|
||||
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 Polyline
|
||||
{
|
||||
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")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue