XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
808 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
TileSource Unable to load openstreetmap
XAML
<map:Map x:Name="map" ZoomLevel="5" Center="39.9132801985722,116.392009995601,0">
<map:Map.Mode>
<map:MercatorMode/>
</map:Map.Mode>
<local:OpenstreetmapTileLayer UriFormat="https://tile.openstreetmap.org/{z}/{x}/{y}.png"/>
</map:Map>
XAML.CS
public class OpenstreetmapTileLayer : MapTileLayer
{
public OpenstreetmapTileLayer()
{
TileSource = new OpenstreetmapTileSource();
}
public string UriFormat
{
get { return TileSource.UriFormat; }
set { TileSource.UriFormat = value; }
}
}
public class OpenstreetmapTileSource: TileSource
{
public override Uri GetUri(int x, int y, int zoomLevel)
{
var uri= new Uri(UriFormat.
Replace("{x}", x.ToString()).
Replace("{y}", y.ToString()).
Replace("{z}", zoomLevel.ToString()));
Console.WriteLine(uri);
return uri;
}
}
]1