问题描述
我已经使用this instruction向WPF应用程序中添加了MapControl
。我想在其中添加自定义地图图层,因此我使用this instruction添加了OpenStreetMap
切片图层。我想完全删除默认地图,但这不起作用。
我已经在UWP应用中测试了原始MapControl
,并且可以使用。
我在WPF中的代码:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls"
Title="MainWindow" Height="450" Width="800">
<Grid>
<controls:MapControl x:Name="mapControl" />
</Grid>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
HttpMapTileDataSource dataSource = new HttpMapTileDataSource("http://c.tile.openstreetmap.org/{zoomlevel}/{x}/{y}.png");
MapTileSource tileSource = new MapTileSource(dataSource);
tileSource.Visible = true;
tileSource.Layer = MapTileLayer.BackgroundReplacement;
tileSource.IsFadingEnabled = false;
mapControl.Style = Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT.MapStyle.None;
mapControl.TileSources.Add(tileSource);
}
}
这是WPF应用程序。它在顶部显示OpenStreetMap
图层和默认Bing
地图图层:
这是UWP应用,仅完美显示OpenStreetMap
:
有什么解决方案可以在WPF中修复吗?
更新
我发现此行无法正确应用,并导致了错误:
mapControl.Style = Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT.MapStyle.None;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)