I need help regarding c# desktop application . How to display google earth in webbrowser control in c# desktop application( Lat and long pick from datagridview) without using api.
Asked
Active
Viewed 1,062 times
0
-
1Use the same URL you would in a browser. Do it manually first. Then use following in c# : webBrowser1.Navigate("url"); – jdweng Sep 02 '20 at 10:36
1 Answers
0
Pre-requisite: CefSharp.WinForms
via Nuget, reference Cefsharp. Note there are some limitations when using the default webBrowser control that's why I used Cefsharp for this. You can read this article C# webBrowser script error.
Article about Fun stuff to do with the new Google Earth URL.
private const string googleEarthUrl = "https://earth.google.com/web/@{0},{1},{2}a,{3}d";
private ChromiumWebBrowser browser;
private decimal locationAltitude = 200;
private decimal distanceOfEyeFromThePoint = 500000;
Initialize
browser = new ChromiumWebBrowser(getLocationUrl());
gbGoogleEarth.Controls.Add(browser);
Get Location URL
private string getLocationUrl()
{
return string.Format(googleEarthUrl, txtLatitude.Text, txtLongitude.Text, distanceOfEyeFromThePoint, locationAltitude);
}
Submit
browser.Load(getLocationUrl());

tontonsevilla
- 2,649
- 1
- 11
- 18