Sunday, May 6, 2012

Investigation: "'google' is undefined" - while working with Google Map Controls

Recently, I ran into a strange issue while working with Google Map Controls.
I was using GoogleMap Controls version 6.0, and for that I included "Artem.Google.dll" downloaded from codeplex site.
My webpage has only "asp:ScriptManager", and a google map control from Artem.Google.UI namespace.

It was working fine with Firefox and other browsers, but it was giving me error of "'google' is undefined in some javascript. Though I had no javascript in my webpage, I could easily guess this is somewhere in Web resources that's been requested from Artem.Google.DLL.
Even I tried with the sample solution codeplex has provided, and I was facing the same issue in IE and Chrome.

Finally, when I ran fiddler alongside browsing the website in Internet Explorer, I could see some of the javascripts (which are added as web resources in DLL) are not getting downloaded, and the reason was the firewall security rules. Once I unblocked specific contents from firewall, it started working!

So whenever you face this issue, make sure your internet explorer is able to access all the java scripts that are being referenced as a web resource in your DLL.

You can easily check this in a fiddler.
Keep Fiddler running while attempting to access your site in Internet Explorer.
Once you receive "'google' is undefined error", move back to Fiddler, and check on which request it failed. 
To check that, just select any resource request entry in left-hand side pan, and click "webview" tab on right-hand side to see what response it got while requesting a resource.

Hope this will help!

No comments:

Post a Comment

Thanks for visiting my blog.
However, if this helped you in any way, please take a moment to write a comment.

Thanks
Nirman