3

hello all i am creating a winform app in which i am showing a map to all the user but the problem is web browser control is taking ie7 as a default browser and map is not supporting in that particular browser,

error:

You are using a browser that is not supported by the Google Maps JavaScript API. Consider changing your browser.Learn moreDismiss

i want to open the map from web browser control but not with ie, i want to show with google chrome to get rid of that error,

and i have many administrative rights in my system i can't use registry

is there any ways to do that?

  • 1
    You may try [Feature Browser Emulation](https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx). – Equalsk Oct 06 '17 at 07:03
  • 1
    [How can I get the WebBrowser control to show modern contents?](https://stackoverflow.com/q/38514184/3110834) – Reza Aghaei Oct 06 '17 at 07:15

2 Answers2

5

VS default browser control use IE. You should use cefsharp for chrome browser. First include the library and initialize like this...

public ChromiumWebBrowser browser;
private void InitBrowser()
    {
        try
        {
            if (!Cef.IsInitialized)
            {
                CefSettings settings = new CefSettings();
                settings.BrowserSubprocessPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "CefSharp.BrowserSubprocess.exe");

                Cef.Initialize(settings);
            }
            string url = "www.google.com";

            browser = new ChromiumWebBrowser(url);             
            this.Controls.Add(browser);
            browser.Dock = DockStyle.Fill;

            browser.IsBrowserInitializedChanged += browser_IsBrowserInitializedChanged;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }
    }

    private void browser_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
    {
        if (((ChromiumWebBrowser)sender).IsBrowserInitialized)
        {
            //if needed then use dev tool
            browser.ShowDevTools();
        }
    }

For more info please see below link... https://github.com/cefsharp/CefSharp https://github.com/cefsharp/CefSharp/wiki/Quick-Start

Monowar
  • 106
  • 5
1

The Browser component uses the Internet Explorer as engine, so if you want another browser you have to find a component for that.

CefSharp uses chromium as engine.

einord
  • 2,278
  • 2
  • 20
  • 26