如何在wpf窗口中加载谷歌地图? [英] How to load Google Maps in wpf window?

查看:157
本文介绍了如何在wpf窗口中加载谷歌地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在wpf窗口中加载Google地图?如果是,我该怎么做?
我使用visual studio-2010和DevExpress工具。
我从DevExpress官方网站找到的openstreetmaps代码。

 常量字符串roadUrlTemplate = @HTTP:// {子域} .tile.openstreetmap.org / {tileLevel} / {tileX } / {tileY} png格式; 


解决方案

是的,您可以使用 GDS Google Map WinForms Control 。在这里它如何:


  1. 创建一个WPF应用程序并制作以下​​XAML:


  2. 添加对GdsGoogleMap.dll的引用; / p>


  3. 编码如下:

  4.  命名空间MapWpfApp 

    {

    ///< summary>
    /// MainWindow.xaml的交互逻辑
    ///< / summary>
    public partial class MainWindow
    {
    private readonly GdsGoogleMap.GdsGoogleMap _gdsGoogleMap;

    public MainWindow()
    {
    InitializeComponent();
    _gdsGoogleMap = new GdsGoogleMap.GdsGoogleMap();
    WindowsFormsHost.Child = _gdsGoogleMap;
    }
    }
    }




    1. 编译并运行该程序,您将在WPF窗口中看到Google Map。


    Is it possible to load Google Maps in wpf window? If yes how can i do this? I'm using visual studio-2010 and DevExpress tool. This code i found from DevExpress official site for openstreetmaps.

    const string roadUrlTemplate = @"http://{subdomain}.tile.openstreetmap.org/{tileLevel}/{tileX}/{tileY}.png";
    

    解决方案

    Yes, you can do it by using GDS Google Map WinForms Control. Here it how:

    1. Create a WPF application and make the following XAML:

    2. Add a reference to GdsGoogleMap.dll;

    3. Code the followings:

     

    namespace MapWpfApp
    
    {
    
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow
        {
            private readonly GdsGoogleMap.GdsGoogleMap _gdsGoogleMap;
    
            public MainWindow()
            {
                InitializeComponent();
                _gdsGoogleMap = new GdsGoogleMap.GdsGoogleMap();
                WindowsFormsHost.Child = _gdsGoogleMap;
            }
        }
    }
    

    1. Compile and run the program and you will see the Google Map on WPF window.

    这篇关于如何在wpf窗口中加载谷歌地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆