GWT Maps API not loading

483 views
Skip to first unread message

martind

unread,
Sep 7, 2009, 6:50:55 PM9/7/09
to Google Web Toolkit
Hi all,

I'm using:
- GWT 1.7.0
- gwt-maps 1.0.4
- GAE 1.2.5
- Eclipse 3.5 with the Google plugin
- Sun JDK 1.0.6_16
- linux (Fedora 11)

A few weeks ago, I began a project using gwt-maps which worked fine.
But somehow it got broken recently. I get the following error in
hosted mode:

[ERROR] Unable to load module entry point class test.client.Test (see
associated exception for details)
java.lang.RuntimeException: The Maps API has not been loaded.
Is a <script> tag missing from your host HTML or module file? Is the
Maps key missing or invalid?
at com.google.gwt.maps.client.Maps.assertLoaded(Maps.java:32)
at com.google.gwt.maps.client.geom.LatLng$.newInstance(Native Method)
at test.client.Test.onModuleLoad(Test.java:46)

My Test.gwt.xml file is the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//
EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-
source/core/src/gwt-module.dtd">
<module rename-to='test'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<inherits name="com.google.gwt.maps.GoogleMaps" />
<script src="http://maps.google.com/maps?
gwt=1&amp;file=api&amp;v=2&amp;sensor=false" />

<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

<!-- Other module inherits -->

<!-- Specify the app entry point class. -->
<entry-point class='test.client.Test'/>
</module>


I used wireshark to debug and it seems that "http://maps.google.com/
maps?gwt=1&amp;file=api&amp;v=2&amp;sensor=false" is never acessed. If
I try loading the URL in my browser it works fine.

At first I thought it was an issue with Fedora Eclipse or with OpenJDK
so I replaced them with the "official" eclipse and Sun JDK but no
luck...

Has anybody got the same issue ?

Eric Ayers

unread,
Sep 8, 2009, 11:27:21 AM9/8/09
to google-we...@googlegroups.com
1) Have you tried running it with a Maps key installed as the error
message suggests?

2) Are you on Windows? If so, have your IE cache/proxy/security
settings changed recently? That sometimes gets in the way of the
Google APIs requests.
--
Google Code Jam 2009
http://code.google.com/codejam

martind

unread,
Sep 12, 2009, 5:48:28 PM9/12/09
to Google Web Toolkit
1) yes, I have tried running it with a Maps key. I also tried
generating a new one with no luck.

2) no, I am on Fedora 11 with Firefox 3.5.3

I have another error related to the Maps API which might help diagnose
the problem:

[ERROR] Unable to load module entry point class
com.coopiz.client.Coopiz (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError):
$wnd.GClientGeocoder is not a constructor
fileName: transient source for
com.google.gwt.maps.client.impl.__GeocoderImplImpl
lineNumber: 30
stack: ()@transient source for
com.google.gwt.maps.client.impl.__GeocoderImplImpl:30
gwtOnLoad([object Window],"coopiz","1.6")@:0
gwtOnLoad(undefined,"coopiz","http://localhost:8080/coopiz/")@http://
localhost:8080/coopiz/hosted.html?coopiz:20
qc()@http://localhost:8080/coopiz/coopiz.nocache.js:2
()@http://localhost:8080/coopiz/coopiz.nocache.js:8
@http://localhost:8080/coopiz/hosted.html?coopiz:39

at com.google.gwt.maps.client.impl.__GeocoderImplImpl.construct
(Native Method)
at com.google.gwt.maps.client.geocode.Geocoder.<init>(Geocoder.java:
41)
at com.coopiz.client.model.PersistenceManager.<init>
(PersistenceManager.java:26)
at com.coopiz.client.controllers.ApplicationController.<init>
(ApplicationController.java:14)
...


If I comment the portion of code which generates the error above, I
get the error reported in the first message of this thread.


Could it have something to do with an upgrade from GWT 1.6 to 1.7 ? I
just checked the upgrade steps but maybe I missed something ?

Eric Ayers

unread,
Sep 12, 2009, 5:57:52 PM9/12/09
to google-we...@googlegroups.com
I've not heard of problems using the Maps API with GWT 1.7. Can you
use firebug or some other way to trace your network messages and see
that indeed the script tag you've got in your module specification is
working?

martind

unread,
Sep 13, 2009, 11:34:24 AM9/13/09
to Google Web Toolkit
If I compile my application and run it in my system browser, it works
fine. Firebug raises no issues.

However, it fails in hosted mode...

martind

unread,
Sep 18, 2009, 9:33:17 PM9/18/09
to Google Web Toolkit
I formatted my disk and reinstalled Fedora 11 yesterday. I do not
encounter the problem anymore.
I guess I will never know what was wrong ;)

George Georgovassilis

unread,
Sep 19, 2009, 9:42:04 AM9/19/09
to Google Web Toolkit
Sorry to hijack this thread, but since we're talking about this...
what's the best way of loading the maps API javascriptlibrary without
blocking (aka unblocking parallel downloads)?

So far I ended up with this:

<script type="text/javascript">
//<![CDATA[
function loadGoogleMapsAPI(){
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps?
file=api&v=2&async=2&sensor=false&key=XYZ";
document.body.appendChild(script);
}
window.setTimeout("loadGoogleMapsAPI()",1);
//]]>

Martin Delemotte

unread,
Sep 19, 2009, 9:56:43 AM9/19/09
to google-we...@googlegroups.com
Have a look at AjaxLoader:

AjaxLoader.init("your maps key here");
        AjaxLoader.loadApi("maps", "2", new Runnable() {
            public void run() {
                //action to perform after api is loaded
            }
        }, null);

George Georgovassilis

unread,
Sep 20, 2009, 3:06:26 AM9/20/09
to Google Web Toolkit
Hello Martin,

Look lot cleaner than my solution - however I see a certain
performance penalty with that. The bootstrap process with your example
is:

1. load host page
2. load .nocache.js
3. load .cache.js
4. load google maps API

and it's all serialized.

With the direct injection of the code into the html the bootstrap
process is shortened, because GWT's module and the Maps API load in
parallel:

1. load host page
2. load .nocache.js and google maps API in parallel
3. load .cache.js

what do you think?


On Sep 19, 4:56 pm, Martin Delemotte <martin.delemo...@gmail.com>
wrote:
> Have a look at AjaxLoader:
>
> AjaxLoader.init("your maps key here");
>         AjaxLoader.loadApi("maps", "2", new Runnable() {
>             public void run() {
>                 //action to perform after api is loaded
>             }
>         }, null);
>
> On Sat, Sep 19, 2009 at 9:42 AM, George Georgovassilis <
>

Martin Delemotte

unread,
Sep 20, 2009, 1:21:13 PM9/20/09
to google-we...@googlegroups.com
Yes, you are right indeed.

This is a tradeoff between clean code and performance penalty. From where I test it is 184ms which is quite negligible compared to the time it takes to load maps...

Martin Delemotte

unread,
Sep 20, 2009, 1:26:30 PM9/20/09
to google-we...@googlegroups.com
I forgot to mention, the loading order is:


1. load host page
2. load .nocache.js
    4. load google maps API
    3. load .cache.js

with 3 and 4 in parallel

George Georgovassilis

unread,
Sep 20, 2009, 1:42:17 PM9/20/09
to google-we...@googlegroups.com
Hi Martin,

my ping alone is 170ms, so I won't explore this argument further. Also I
think the comparison between loading a map and the map API is not
correct - I am comparing the time needed to show my application with and
without the maps API (always taking the naive, blocking approach) and at
least for recurring visitors, the difference in user experience is notable.

Are you sure 3 and 4 are loaded simultaneously with the AjaxLoader? As
far as my understanding of the bootstrap process goes, 4 is launched by
the application itself, which cannot be sooner than 3 is loaded.

Martin Delemotte wrote:
> I forgot to mention, the loading order is:
>
> 1. load host page
> 2. load .nocache.js
> 4. load google maps API
> 3. load .cache.js
>
> with 3 and 4 in parallel
>
>
>
> On Sun, Sep 20, 2009 at 1:21 PM, Martin Delemotte
> <martin.d...@gmail.com <mailto:martin.d...@gmail.com>> wrote:
>
> Yes, you are right indeed.
>
> This is a tradeoff between clean code and performance penalty.
> From where I test it is 184ms which is quite negligible compared
> to the time it takes to load maps...
>
>
>
>
> On Sun, Sep 20, 2009 at 3:06 AM, George Georgovassilis
> <g.georgo...@gmail.com <mailto:g.georgo...@gmail.com>>
> wrote:
>
>
> Hello Martin,
>
> Look lot cleaner than my solution - however I see a certain
> performance penalty with that. The bootstrap process with your
> example
> is:
>
> 1. load host page
> 2. load .nocache.js
> 3. load .cache.js
> 4. load google maps API
>
> and it's all serialized.
>
> With the direct injection of the code into the html the bootstrap
> process is shortened, because GWT's module and the Maps API
> load in
> parallel:
>
> 1. load host page
> 2. load .nocache.js and google maps API in parallel
> 3. load .cache.js
>
> what do you think?
>
>
> On Sep 19, 4:56 pm, Martin Delemotte
> <martin.delemo...@gmail.com <mailto:martin.delemo...@gmail.com>>
> wrote:
> > Have a look at AjaxLoader:
> >
> > AjaxLoader.init("your maps key here");
> > AjaxLoader.loadApi("maps", "2", new Runnable() {
> > public void run() {
> > //action to perform after api is loaded
> > }
> > }, null);
> >
> > On Sat, Sep 19, 2009 at 9:42 AM, George Georgovassilis <
> >
> > g.georgovassi...@gmail.com
> <mailto:g.georgovassi...@gmail.com>> wrote:
> >
> > > Sorry to hijack this thread, but since we're talking about
> this...
> > > what's the best way of loading the maps API
> javascriptlibrary without
> > > blocking (aka unblocking parallel downloads)?
> >
> > > So far I ended up with this:
> >
> > > <script type="text/javascript">
> > > //<![CDATA[
> > > function loadGoogleMapsAPI(){
> > > var script = document.createElement("script");
> > > script.type = "text/javascript";
> > > script.src = "http://maps.google.com/maps?
> > > file=api&v=2&async=2&sensor=false&key=XYZ";
> > > document.body.appendChild(script);
> > > }
> > > window.setTimeout("loadGoogleMapsAPI()",1);
> > > //]]>
> >
> > > On Sep 19, 4:33 am, martind <martin.delemo...@gmail.com
> <mailto:martin.delemo...@gmail.com>> wrote:
> > > > I formatted my disk and reinstalled Fedora 11 yesterday.
> I do not
> > > > encounter the problem anymore.
> > > > I guess I will never know what was wrong ;)
> >
> > > > On Sep 13, 11:34 am, martind <martin.delemo...@gmail.com
> <mailto:martin.delemo...@gmail.com>> wrote:
> >
> > > > > If I compile my application and run it in my system
> browser, it works
> > > > > fine. Firebug raises no issues.
> >
> > > > > However, it fails in hosted mode...
> >
> > > > > On Sep 12, 5:57 pm, Eric Ayers <zun...@google.com
> <mailto:zun...@google.com>> wrote:
> >
> > > > > > I've not heard of problems using the Maps API with
> GWT 1.7. Can you
> > > > > > use firebug or some other way to trace your network
> messages and see
> > > > > > that indeed the script tag you've got in your module
> specification is
> > > > > > working?
> >
> > > > > > On Sat, Sep 12, 2009 at 5:48 PM,
> martind<martin.delemo...@gmail.com
> <mailto:martin.delemo...@gmail.com>>
> <mailto:zun...@google.com>> wrote:
> > > > > > >> 1) Have you tried running it with a Maps key
> installed as the
> > > error
> > > > > > >> message suggests?
> >
> > > > > > >> 2) Are you on Windows? If so, have your IE
> cache/proxy/security
> > > > > > >> settings changed recently? That sometimes gets
> in the way of the
> > > > > > >> Google APIs requests.
> >
> > > > > > >> On Mon, Sep 7, 2009 at 6:50 PM, martind<
> > > martin.delemo...@gmail.com
0x3F294C9C.asc

Martin Delemotte

unread,
Sep 20, 2009, 10:59:39 PM9/20/09
to google-we...@googlegroups.com
Yes, 3 then 4. And there are not in parallel.

Thanks to you I realised I had kept the Maps API tag in my Module.gwt.xml and that I was loading Maps API two times.

I am afraid it wont help you with your problem but thanks ;)



-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (MingW32)

mQGiBEhu77QRBADVjvOwXu9KoF9LUeDlP3vqFvc5S9x9DdOF1V6De5aCAcSqkdMA
1WNyPTiP1WQyrujOG6JmUTYLJ16pq7fgaVmmCUOizmpnv0/fzc+j3JROJeZEI5ik
yq1ONz9DaVDoF28ITd4sdfYKxcPk1LQDiGKsy4jHy43STGlFTq74aV8iwwCg/YJ9
Pee9QwhWuTko9CqreY+oQvUEAMNCj9lSoyzveEWpvDtfZuTWOKZTzHjMThZtJFtP
wr+NuSS/WIFNUPo0enjc7xhpS1eUNVasXXGvTP0PiJYfirg0YCrLMm5hEkcPxwgf
ksdYKebDlw5PDUWw6VKWVU/Ft6qDPNmyRmn7WMTy6UFSAkb5AOgOsBfxnUrgMdvP
ql7wA/9f20OkSt6UXdSBT9Q46oLpW+sj+zcWWGlJ9XhOzseVJtgj50IKX8VU8qGT
2k0+GTC0KZHYVrzMxWtk+6JlxguNosDJdW90Kd6CmVqWmTSAx18BWEL8iTEyDw9Z
SPewWD8XpmE3jc7038UkTykmchbJjmwbS5LWZ4VYphVfbskTPbQyR2VvcmdlIEdl
b3Jnb3Zhc3NpbGlzIDxnLmdlb3Jnb3Zhc3NpbGlzQGdtYWlsLmNvbT6IZgQTEQIA
JgUCSG7vtAIbIwUJCW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