没有地图显示在C#Visual Studio 2013的WPF GMAP.NET中

时间:2015-10-05 17:19:16

标签: c# wpf visual-studio openstreetmap gmap.net

我想在基于OpenStreetMap的地图上显示一个点。我正在研究GM#.NET(来自http://greatmaps.codeplex.com/的控制库)来自C#Visual Studio 2013的WPF。

当我跑步时,只出现一个窗口。但是,地图无法显示。

如何解决此问题?

这是我的代码:

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>

1 个答案:

答案 0 :(得分:1)

尝试更改缩放设置:

...
myMap.MinZoom = 3;
myMap.MaxZoom = 17;
...