mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-13 18:35:18 +00:00
Changed IMapLayer interface
This commit is contained in:
parent
57ee896f8a
commit
1d4c5a4b90
8 changed files with 28 additions and 32 deletions
|
|
@ -23,7 +23,6 @@ namespace MapControl
|
|||
{
|
||||
Brush MapBackground { get; }
|
||||
Brush MapForeground { get; }
|
||||
IReadOnlyCollection<string> SupportedCrsIds { get; }
|
||||
}
|
||||
|
||||
public partial class MapBase
|
||||
|
|
@ -40,7 +39,7 @@ namespace MapControl
|
|||
/// Gets or sets the base map layer, which is added as first element to the Children collection.
|
||||
/// If the passed object is not a FrameworkElement, MapBase tries to locate a DataTemplate
|
||||
/// resource for the object's type and generate a FrameworkElement from that DataTemplate.
|
||||
/// If the FrameworkElement implements IMapLayer (like e.g. MapTileLayer or MapImageLayer),
|
||||
/// If the FrameworkElement implements IMapLayer (like e.g. TilePyramidLayer or MapImageLayer),
|
||||
/// its (non-null) MapBackground and MapForeground property values are used for the MapBase
|
||||
/// Background and Foreground.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
|
|
@ -127,11 +126,6 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public double LoadingProgress => (double)GetValue(LoadingProgressProperty);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all CRSs supported by a MapImageLayer.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<string> SupportedCrsIds { get; protected set; }
|
||||
|
||||
protected override void SetParentMap(MapBase map)
|
||||
{
|
||||
if (map != null)
|
||||
|
|
@ -182,8 +176,7 @@ namespace MapControl
|
|||
ImageSource image = null;
|
||||
Rect? mapRect = null;
|
||||
|
||||
if (ParentMap != null &&
|
||||
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
|
||||
if (ParentMap != null)
|
||||
{
|
||||
var width = ParentMap.ActualWidth * RelativeImageSize;
|
||||
var height = ParentMap.ActualHeight * RelativeImageSize;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -57,8 +56,6 @@ namespace MapControl
|
|||
this.SetRenderTransform(new MatrixTransform());
|
||||
}
|
||||
|
||||
public override IReadOnlyCollection<string> SupportedCrsIds { get; } = [WebMercatorProjection.DefaultCrsId];
|
||||
|
||||
public TileMatrix TileMatrix { get; private set; }
|
||||
|
||||
public ICollection<ImageTile> Tiles { get; private set; } = [];
|
||||
|
|
@ -149,7 +146,7 @@ namespace MapControl
|
|||
|
||||
private void UpdateTileCollection(bool tileSourceChanged)
|
||||
{
|
||||
if (TileSource == null || ParentMap == null || !SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId))
|
||||
if (TileSource == null || ParentMap?.MapProjection.CrsId != WebMercatorProjection.DefaultCrsId)
|
||||
{
|
||||
CancelLoadTiles();
|
||||
Children.Clear();
|
||||
|
|
|
|||
|
|
@ -171,8 +171,6 @@ namespace MapControl
|
|||
|
||||
public bool IsBaseMapLayer => ParentMap != null && ParentMap.Children.Count > 0 && ParentMap.Children[0] == this;
|
||||
|
||||
public abstract IReadOnlyCollection<string> SupportedCrsIds { get; }
|
||||
|
||||
protected void BeginLoadTiles(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName)
|
||||
{
|
||||
TileImageLoader.BeginLoadTiles(tiles, tileSource, cacheName, loadingProgress);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public IReadOnlyCollection<string> AvailableLayers { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all CRSs supported by a WMS.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<string> SupportedCrsIds { get; private set; }
|
||||
|
||||
private bool HasLayer =>
|
||||
RequestLayers != null ||
|
||||
AvailableLayers?.Count > 0 ||
|
||||
|
|
@ -113,17 +118,17 @@ namespace MapControl
|
|||
var ns = capabilities.Name.Namespace;
|
||||
var capability = capabilities.Element(ns + "Capability");
|
||||
|
||||
SupportedCrsIds = capability
|
||||
.Descendants(ns + "Layer")
|
||||
.Descendants(ns + "CRS")
|
||||
.Select(e => e.Value)
|
||||
.ToList();
|
||||
|
||||
AvailableLayers = capability
|
||||
.Descendants(ns + "Layer")
|
||||
.Select(e => e.Element(ns + "Name")?.Value)
|
||||
.Where(n => !string.IsNullOrEmpty(n))
|
||||
.ToList();
|
||||
|
||||
SupportedCrsIds = capability
|
||||
.Descendants(ns + "Layer")
|
||||
.Descendants(ns + "CRS")
|
||||
.Select(e => e.Value)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +166,8 @@ namespace MapControl
|
|||
string response = null;
|
||||
|
||||
if (ServiceUri != null && HasLayer &&
|
||||
ParentMap != null && ParentMap.InsideViewBounds(position))
|
||||
ParentMap != null && ParentMap.InsideViewBounds(position) &&
|
||||
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
|
||||
{
|
||||
var uri = GetFeatureInfoRequestUri(position, format);
|
||||
|
||||
|
|
@ -185,7 +191,8 @@ namespace MapControl
|
|||
{
|
||||
ImageSource image = null;
|
||||
|
||||
if (ServiceUri != null && HasLayer)
|
||||
if (ServiceUri != null && HasLayer &&
|
||||
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
|
||||
{
|
||||
var xMin = -180d * MapProjection.Wgs84MeterPerDegree;
|
||||
var xMax = 180d * MapProjection.Wgs84MeterPerDegree;
|
||||
|
|
|
|||
|
|
@ -79,11 +79,6 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public Dictionary<string, WmtsTileMatrixSet> TileMatrixSets { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all CRSs supported by a WMTS.
|
||||
/// </summary>
|
||||
public override IReadOnlyCollection<string> SupportedCrsIds => TileMatrixSets.Keys;
|
||||
|
||||
protected IEnumerable<TileMatrixLayer> ChildLayers => Children.Cast<TileMatrixLayer>();
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,15 @@ namespace MapControl.UiTools
|
|||
|
||||
protected override bool GetIsEnabled(MapBase map)
|
||||
{
|
||||
return map.MapLayer is not IMapLayer mapLayer
|
||||
|| mapLayer.SupportedCrsIds == null
|
||||
|| mapLayer.SupportedCrsIds.Contains(CrsId);
|
||||
var supportedCrsIds = map.MapLayer switch
|
||||
{
|
||||
WmsImageLayer wmsImageLayer => wmsImageLayer.SupportedCrsIds,
|
||||
WmtsTileLayer wmtsTileLayer => wmtsTileLayer.TileMatrixSets.Keys,
|
||||
MapTileLayer => [WebMercatorProjection.DefaultCrsId],
|
||||
_ => null
|
||||
};
|
||||
|
||||
return supportedCrsIds == null || supportedCrsIds.Contains(CrsId);
|
||||
}
|
||||
|
||||
protected override bool GetIsChecked(MapBase map)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<DefineConstants>UWP</DefineConstants>
|
||||
<RootNamespace>MapControl.UiTools</RootNamespace>
|
||||
<AssemblyTitle>XAML Map Control UI Tools Library for UWP</AssemblyTitle>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue