如何在 wpf 窗口中加载 Google 地图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23903586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 00:06:07  来源:igfitidea点击:

How to load Google Maps in wpf window?

wpfgoogle-mapsdevexpress

提问by

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.

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

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

回答by rbrundritt

If you are not limited to using Google Maps then take a look at the Bing Maps WPF control for a truly native WPF map solution:

如果您不仅限于使用 Google 地图,请查看 Bing Maps WPF 控件以获得真正的原生 WPF 地图解决方案:

http://msdn.microsoft.com/en-us/library/hh750210.aspx

http://msdn.microsoft.com/en-us/library/hh750210.aspx

If you need to use Google Maps you can of course use a web browser control and create an interlop to communicate between C# and JavaScript however if you want a native WPF solution then take a look at some open source solutions like the following:

如果您需要使用 Google 地图,您当然可以使用 Web 浏览器控件并创建一个互操作以在 C# 和 JavaScript 之间进行通信,但是如果您想要本机 WPF 解决方案,请查看一些开源解决方案,如下所示:

http://greatmaps.codeplex.com/

http://greatmaps.codeplex.com/

https://github.com/ericnewton76/gmaps-api-net

https://github.com/ericnewton76/gmaps-api-net

回答by Leon

An easy way is to use the WebBrowser control. In XAML add:

一种简单的方法是使用 WebBrowser 控件。在 XAML 中添加:

<WebBrowser x:Name="wbMaps" Source="https://www.google.com/maps"/>