mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 15:05:50 +00:00
Version 4.17.0: Added support for WMTS
This commit is contained in:
parent
e650c9081f
commit
e821e39841
38 changed files with 991 additions and 307 deletions
35
MapControl/Shared/WmtsTileSource.cs
Normal file
35
MapControl/Shared/WmtsTileSource.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2020 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class WmtsTileSource : TileSource
|
||||
{
|
||||
private readonly IList<WmtsTileMatrix> tileMatrixes;
|
||||
|
||||
public WmtsTileSource(string uriFormat, WmtsTileMatrixSet tileMatrixSet)
|
||||
: base(uriFormat.Replace("{TileMatrixSet}", tileMatrixSet.Identifier))
|
||||
{
|
||||
tileMatrixes = tileMatrixSet.TileMatrixes;
|
||||
}
|
||||
|
||||
public override Uri GetUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
if (zoomLevel < 0 || zoomLevel >= tileMatrixes.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var url = UriFormat
|
||||
.Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier)
|
||||
.Replace("{TileCol}", x.ToString())
|
||||
.Replace("{TileRow}", y.ToString());
|
||||
|
||||
return new Uri(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue