简体   繁体   English

在C#Webbrowser中显示Google Earth

[英]show google earth in c# webbrowser

since some days google earth is directly available via browsers like edge or internetexplorer. 由于某些天以来,可以通过Edge或Internetexplorer等浏览器直接访问google Earth。 However, if a create a Webbrowser control in wpf and navigate to google.com/maps and click on "satellite view", the website tells me, that google earth view is not available for me. 但是,如果在wpf中创建一个Webbrowser控件并导航到google.com/maps并单击“卫星视图”,则该网站会告诉我,我无法使用google Earth视图。 Compare both views: 比较两个视图:

Images can be found here: 图片可以在这里找到:
http://wb20.stedum-bekum.de/wp-content/uploads/2017/10/Webbrowser.png http://wb20.stedum-bekum.de/wp-content/uploads/2017/10/Webbrowser.png
http://wb20.stedum-bekum.de/wp-content/uploads/2017/10/IE.png http://wb20.stedum-bekum.de/wp-content/uploads/2017/10/IE.png

*the yellow rectangle sais: 3d View not available *黄色矩形表示:3d视图不可用

In my code i set User Agent manuelly and update it via urlmon in the navigating event. 在我的代码中,我手动设置了用户代理,并在导航事件中通过urlmon对其进行了更新。

webbrowser.Navigate(new Uri("https://google.de/maps"), null, null, "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv: 11.0) like Gecko \r\n");

and

   [DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
   private static extern int UrlMkSetSessionOption(
   int dwOption, string pBuffer, int dwBufferLength, int dwReserved);

    const int URLMON_OPTION_USERAGENT = 0x10000001;
    const int URLMON_OPTION_USERAGENT_REFRESH = 0x10000002;

    public void ChangeUserAgent(string agent)
    {

        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, null, 0, 0);
        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, agent, agent.Length, 0);
    }

and i also changed webbrowser to behave like ie via FEATURE_BROWSER_EMULATION 而且我还更改了网络浏览器的行为,例如通过FEATURE_BROWSER_EMULATION

does anybody have an idea how to use it in webbrowser? 有没有人知道如何在网络浏览器中使用它?

I also tried dotnetbrowser to integrate. 我还尝试了dotnetbrowser进行集成。 This worked for some days, but now i get the same message. 这工作了几天,但现在我收到了同样的消息。

I also tried firefox, edge and chrome (outside of my code), they are all working fine like IE. 我还尝试了firefox,edge和chrome(在我的代码之外),它们都像IE一样正常工作。

I found out. 我发现。 For anyone who need the same, the problem was Webbrowser Hardware acceleration is turned off by default. 对于任何需要相同功能的人,问题在于Webbrowser硬件加速默认情况下处于关闭状态。 You can set 你可以设定

FEATURE_GPU_RENDERING to 1 in Registry as statet here FEATURE_GPU_RENDERING在注册表中设为1
https://msdn.microsoft.com/en-us/library/ee330731(v=VS.85).aspx https://msdn.microsoft.com/zh-CN/library/ee330731(v=VS.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM