C# Visual Studio 2013 中的 WPF GMAP.NET 中未显示地图
No map shown up in WPF GMAP.NET from C# Visual Studio 2013
我想根据 OpenStreetMap. I am working on GMAP.NET (a control library at http://greatmaps.codeplex.com/) WPF from C# Visual Studio 2013 在地图上显示一个点。
当我 运行 它时,只有一个 window 出现了。但是,地图无法显示。
我该如何解决这个问题?
这是我的代码:
MainWindow.xaml.cs:
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GMap.NET;
using GMap.NET.WindowsPresentation;
using GMap.NET.MapProviders;
namespace try_gmap_wpf
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
GMapControl gMapControl1 = new GMapControl();
myMap.MapProvider = OpenStreetMapProvider.Instance;
//myMap.SetPositionByKeywords("Canada");
//Get tiles from server only
myMap.Manager.Mode = AccessMode.ServerOnly;
//Not use proxy
//Center map on a point
myMap.Position = new PointLatLng(42.742826, -77.030212);
//Zoom min/max; default both = 2
myMap.MinZoom = 1;
myMap.MaxZoom = 2;
//Set zoom
myMap.Zoom = 0;
myMap.ShowCenter = true;
}
}
}
MainWindow.xaml designer:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation" x:Class="try_gmap_wpf.MainWindow"
xmlns:m="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
Title="MainWindow" Height="500" Width="900">
<Grid>
<WindowsPresentation:GMapControl Name="myMap" HorizontalAlignment="Left" Height="500" Margin="10,10,0,0" VerticalAlignment="Top" Width="900"/>
</Grid>
</Window>
尝试更改缩放设置:
...
myMap.MinZoom = 3;
myMap.MaxZoom = 17;
...
我想根据 OpenStreetMap. I am working on GMAP.NET (a control library at http://greatmaps.codeplex.com/) WPF from C# Visual Studio 2013 在地图上显示一个点。
当我 运行 它时,只有一个 window 出现了。但是,地图无法显示。
我该如何解决这个问题?
这是我的代码:
MainWindow.xaml.cs:
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GMap.NET;
using GMap.NET.WindowsPresentation;
using GMap.NET.MapProviders;
namespace try_gmap_wpf
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
GMapControl gMapControl1 = new GMapControl();
myMap.MapProvider = OpenStreetMapProvider.Instance;
//myMap.SetPositionByKeywords("Canada");
//Get tiles from server only
myMap.Manager.Mode = AccessMode.ServerOnly;
//Not use proxy
//Center map on a point
myMap.Position = new PointLatLng(42.742826, -77.030212);
//Zoom min/max; default both = 2
myMap.MinZoom = 1;
myMap.MaxZoom = 2;
//Set zoom
myMap.Zoom = 0;
myMap.ShowCenter = true;
}
}
}
MainWindow.xaml designer:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation" x:Class="try_gmap_wpf.MainWindow"
xmlns:m="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
Title="MainWindow" Height="500" Width="900">
<Grid>
<WindowsPresentation:GMapControl Name="myMap" HorizontalAlignment="Left" Height="500" Margin="10,10,0,0" VerticalAlignment="Top" Width="900"/>
</Grid>
</Window>
尝试更改缩放设置:
...
myMap.MinZoom = 3;
myMap.MaxZoom = 17;
...