GDirection event handler?

11 views
Skip to first unread message

Eric B

unread,
Sep 13, 2007, 11:01:37 AM9/13/07
to Google Web Toolkit
** I posted this on the SourceForge forum for the GWT Google Maps
project, but not sure how much that gets read **

I'm catching the GDirection events using the following:

GEvent.addListener( this.map, "load", this );
GEvent.addListener( this.map, "addoverlay", this );
GEvent.addListener( this.map, "error", this );

But I'm not sure how to get the "source" and "param" parameters of the
"onHandle( JSObject source, JSObject[] param )" method back into Java
objects like GMap2 or String.

Can you please tell me if this is the correct way to catch these
events? If so, what are the Java classes for "source" and "param" so I
can cast them back.

Thanks,
Eric

krispy

unread,
Sep 13, 2007, 11:29:59 AM9/13/07
to Google Web Toolkit
Wow, the GDirections documentation is a mess - but if you can figure
out what each object in the param array should be, then you can cast
it back to GWT/Java by using the narrowTo*(JSObject) method of that
class. For instance, if "param[0]" should be a GMap2, then use
GMap2.narrowToGMap2(source). Looking at the maps documentation, it's
impossible to tell if there are any parameters passed back - it seems
like the "load" event doesn't have any, and it might be the same for
"error" and "addoverlay" - they just kind of let you know something
happened, so that you can check other things (like the status code).
Does that make sense?

-krispy

Eric B

unread,
Sep 13, 2007, 11:34:16 AM9/13/07
to Google Web Toolkit
krispy,
Thanks, that's one part of the puzzle solved. I'm pretty sure that
the source will always be a GMap2 object, but I guess I'll just have
to try it to be sure.

Each event has one param in the JSObject array. I have no idea
what that is. I was hoping it was a string with the even type, like
"load" or "error". Anyone know how to figure this out?

Thanks,
Eric

krispy

unread,
Sep 13, 2007, 1:03:27 PM9/13/07
to Google Web Toolkit
It might just be the GDirections object coming back - looking at some
sample pages it seems that it's not really used:

http://econym.googlepages.com/example_map4c.htm
http://econym.googlepages.com/example_steps.htm

Do a View->Page Source and search the javascript for
"GEvent.addListener" - he checks for a "load" and "error" event, but
just asks the directions object for the status code afterwards. You'd
have to search around the maps api forums or do some javascript coding
to figure out what objects are being passed back - sorry, I think
that's about the best I can do for you.

-krispy

Eric B

unread,
Sep 13, 2007, 1:06:25 PM9/13/07
to Google Web Toolkit
That's true, since the GDirections and GMap2 objects are members of my
handler class, I guess I don't need the onHandle method's parameters
at all. :)

Thanks for your help,
Eric

On Sep 13, 10:03 am, krispy <cplum...@integrity-apps.com> wrote:
> It might just be the GDirections object coming back - looking at some
> sample pages it seems that it's not really used:
>

> http://econym.googlepages.com/example_map4c.htmhttp://econym.googlepages.com/example_steps.htm

krispy

unread,
Sep 13, 2007, 1:12:48 PM9/13/07
to Google Web Toolkit
You could use the new google-apis utility library that miguel and bob
have cooked up:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/80729d40791eca39/b8a6432e8a23ab38

Looking at the source, it might handle things a little better for you
- I haven't had a chance to try it myself, but it looks cleaner than
the alternative.

-krispy

On Sep 13, 1:06 pm, Eric B <ebesse...@gmail.com> wrote:
> That's true, since the GDirections and GMap2 objects are members of my
> handler class, I guess I don't need the onHandle method's parameters
> at all. :)
>
> Thanks for your help,
> Eric
>
> On Sep 13, 10:03 am, krispy <cplum...@integrity-apps.com> wrote:
>
> > It might just be the GDirections object coming back - looking at some
> > sample pages it seems that it's not really used:
>

> >http://econym.googlepages.com/example_map4c.htmhttp://econym.googlepa...

Reply all
Reply to author
Forward
0 new messages