JavaScript error - 'GClientGeocoder' is undefined

Apr 8, 2010 at 1:40 PM
Edited Apr 8, 2010 at 1:41 PM

Not sure if anyone else is having this problem. We have the GoogleMap control on one of our websites and it was working fine until earlier today. Then all of a sudden it stopped working.

Nothing has been changed on the website, but all of a sudden we are getting the following JavaScript error 'GClientGeocoder' is undefined

I have also noticed that the following page generates the same error message: http://googlemap.artembg.com/map/Default.aspx

Has anyone got any ideas what has caused this and how to fix this problem?

Thanks,
Alistair

Aug 23, 2010 at 9:13 AM

It started working the next day without us changing anything.

We had a similar problem last week when it stopped working and then started working again within a few hours.

No idea what the problem was.

Feb 20, 2011 at 5:58 PM

I have this same issue when I embed the map in an updatepanel.

map.checkResize() doesn't seem to fix it either.

Feb 21, 2011 at 3:21 PM

Resolved, solution was to call checkResize in a javascript function, then call that function in the asp tabselectedindexchanged event:

Code Behind  (I'm using a control suite from www.devexpress.com instead of the asp tab control):

/// <summary>
    /// Calls PlotMap which puts a marker on the map for each vendor
    /// Old:Google maps won't display in a tab unless the checkResize() funtion is called
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void AddTab_ActiveTabChanged(object source, DevExpress.Web.ASPxTabControl.TabControlEventArgs e)
    {
        /* map not rendering, possible solution here:
         * http://googlemap.codeplex.com/discussions/32360
         * */
        DevExpress.Web.ASPxTabControl.ASPxPageControl ctl = (DevExpress.Web.ASPxTabControl.ASPxPageControl)gvJobs.FindEditFormTemplateControl("AddTab");
        if (ctl != null)
        {
            GoogleMap map = (GoogleMap)ctl.FindControl("VendorMap");
            if (map != null)
            {
                //string js = "var map = " + map.ClientID + "; if (typeof map != 'undefined') map.checkResize();";
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(@"function ResetMap(){ ");
                sb.AppendLine(@"var map = " + map.ClientID + "; if (typeof map != 'undefined') map.checkResize();");
                sb.AppendLine(@"map.checkResize();}");
                sb.AppendLine(@"function ResetMapDelay(){ ");
                sb.AppendLine(@"");
                sb.AppendLine(@" ");
                sb.AppendLine(@"");
                sb.AppendLine(@"setTimeout(");
                sb.AppendLine(@"");
                sb.AppendLine(@"");
                sb.AppendLine(@"'ResetMap()',50); ");
                sb.AppendLine(@"");
                sb.AppendLine(@" ");
                sb.AppendLine(@"");
                sb.AppendLine(@"}");
                sb.AppendLine(@"");
                //string js = sb.ToString() +  "ResetMapDelay();";
                if (!ClientScript.IsClientScriptBlockRegistered("mapjs")  && IsPostBack)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "mapjs", sb.ToString(), true);
                }
                PlotMap();
            }
        }
    }

ASPX page portion:

<dx:ASPxPageControl ID="AddTab" runat="server" Width="100%" ActiveTabIndex="0" ClientIDMode="AutoID"
                                                    CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue"
                                                    SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css" TabSpacing="0px"
                                                    AutoPostBack="True" EnableCallBacks="False" OnActiveTabChanged="AddTab_ActiveTabChanged">
                                                    <ClientSideEvents ActiveTabChanged="function(s,e){
                                            ResetMapDelay();
                                            }" />
                                                    <TabPages>

Mar 8, 2011 at 10:54 PM

I've been reworking my page to encapsulate everything in an update panel, I've been able to determine that this is caused by an updatepanel.  Removing the update panel resolves the issue.  Grasping at straws to figure out a work around.

Mar 9, 2011 at 12:06 AM

I've got a hack.  I placed another map control above the update panel, set its height to 1px and added the following sytle attribute: style="visibility:hidden"

This eliminated this weird error.

<GMap:GoogleMap runat="server" Key="ABQIAAAAMGSyNRqohAPFAvm90fkpdhRTRnx-x42Y9HgHXo3xDMnxTn361BRvrPA_-WVe0KS_e04-Wa6yV6MGWg"
        Latitude="41" Longitude="-87" Width="100%" Height="1px" ID="VendorMap" InsideUpdatePanel="True" Visible="True" style="visibility:hidden">
    </GMap:GoogleMap>

Mar 9, 2011 at 4:17 PM

This works great, I set the width to 1px, and set all "Enable" properties (i.e. EnableDragging, EnableDoubleClickZoom, etc) to false, and even have the "Enabled"property set to false, works like a charm.

Mar 9, 2011 at 4:18 PM

Also removed "InsideUpdatePanel" for the top map that is outside the updatepanel.