Search This Blog

Thursday, November 24, 2016

C# WebBrowser facing errors when navigating into a page that makes use of (the new 3.25) google maps api


I have a win forms application that makes use of a System.Forms.WebBrowser object, which in turn navigates to a given html that contains several javascript files that makes an api for drawing areas/polygons / adding text labels, among other things, on top of google maps. The problem is that google recently upgraded their api to v3.25, in which they do not support anymore IE versions lower than 10. My WebBrowser object was always emulating an IE 7 browser (not clear why, because after creating a blank winforms project and adding a single WebBrowser into it, to navigate into a page like the mentioned above - but this time hosted locally - the user agent string displayed (after adding alert(this.navigator.userAgent); into the onload event of the body html element) contained no "compatible; MSIE 7;" or alike, rather a rv.11 (referring to IE 11)).
Having the WebBrowser running an emulation of IE 7 was causing javascript errors (Google's api stopped supporting IE versions prior to 10).


The solution that finally worked was this one.


  1. Make sure you have IE 10 or higher installed on the machine serving the uri WebBrowser is to navigate to.
  2. Add the registry values as indicated in the link above - do not forget, when adding the DWORD, to use a key with the exact .exe file where the WebBrowser instance is invoked.
I added another post containing the C# code for fixing this issue (another post because I wanted a post that would catch a closer-to-the-exact-issue title).

Update: The approach above was found to be incomplete, due to part of Google API being deprecated some versions from now (which was still available to 3.4). Make sure you do not make use of MarkerImage, like below.

Click here for google's reference on it, but here's the summary:

No comments:

Post a Comment