【问题标题】:No map shown up in WPF GMAP.NET from C# Visual Studio 2013C# Visual Studio 2013 的 WPF GMAP.NET 中没有显示地图
【发布时间】:2015-10-07 00:11:40
【问题描述】:

我想在基于OpenStreetMap 的地图上显示一个点。我正在使用来自 C# Visual Studio 2013 的 GMAP.NET(http://greatmaps.codeplex.com/ 的控件库)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>

【问题讨论】:

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


    【解决方案1】:

    尝试更改缩放设置:

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

    【讨论】:

      猜你喜欢
      • 2015-04-14
      • 1970-01-01
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      相关资源
      最近更新 更多