Google Maps V3 use with the GWT (JSNI)

388 views
Skip to first unread message

Joe

unread,
Mar 9, 2010, 10:41:17 AM3/9/10
to Google Web Toolkit
Hello everybody!
I try to usethe Google Maps API V3 with the GWT, but it doesn't work.
In a class I have the following method:

public static native JavaScriptObject getMap()/*-{

ar latlng = new google.maps.LatLng(50.940872, 6.937888);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(div, myOptions);
}-*/;

But I always get the error that "google" isn't known. I new that I ave
to include the script-tag. I tried to put it in the xml-File or the
html-File of my GWT2.0 project, but it doesn't work, Does anyone know
who to setup my project to use the Google Maps API V3 with JSNI???
I hope someone could help me...
Thank's a lot
Regards, Joe

Eric Ayers

unread,
Mar 9, 2010, 10:59:42 AM3/9/10
to google-we...@googlegroups.com
Some folks have started a library for Google Maps v3. You can browse some sample cod here:

http://code.google.com/p/gwt-google-maps-v3/source/browse/#hg/src/com/google/gwt/maps/client

From what you describe, it looks like your app is not loading the maps API before calling this code.  


You probably need to add or fix the <script> tag in your host page that loads the Maps API from Google's servers.



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Eric Z. Ayers
Google Web Toolkit, Atlanta, GA USA
Sign up now for Google I/O 2010: May 19-20, http://code.google.com/io

Joe

unread,
Mar 9, 2010, 11:15:25 AM3/9/10
to Google Web Toolkit
Thank's for the fast reply!
The library for Google Maps v3 isn't finished I think and who has to
be the script tag when I want to use the Javascript library with
JSNI?

I tried <script type="text/javascript" src="http://maps.google.com/
maps/api/js?sensor=false"></script>
but that doesn't work?!

Concerning the library for Google Maps v3 it isn'z clear to me, how I
can add all the classes to my existing eclipse-project??

Thanl's and Regards
Joe

On 9 Mrz., 16:59, Eric Ayers <zun...@google.com> wrote:
> Some folks have started a library for Google Maps v3. You can browse some
> sample cod here:
>

> http://code.google.com/p/gwt-google-maps-v3/source/browse/#hg/src/com...


>
> From what you describe, it looks like your app is not loading the maps API
> before calling this code.
>
> http://code.google.com/apis/maps/documentation/v3/introduction.html
>
> You probably need to add or fix the <script> tag in your host page that
> loads the Maps API from Google's servers.

> <http://code.google.com/p/gwt-google-maps-v3/source/browse/#hg/src/com...>


>
> On Tue, Mar 9, 2010 at 10:41 AM, Joe <johannes.speckm...@googlemail.com>wrote:
>
>
>
> > Hello everybody!
> > I try to usethe Google Maps API V3 with the GWT, but it doesn't work.
> > In a class I have the following method:
>
> > public static native JavaScriptObject getMap()/*-{
>
> >        ar latlng = new google.maps.LatLng(50.940872, 6.937888);
> >        var myOptions = {
> >                zoom: 15,
> >                center: latlng,
> >                mapTypeId: google.maps.MapTypeId.ROADMAP
> >        };
> >        var map = new google.maps.Map(div, myOptions);
> > }-*/;
>
> > But I always get the error that "google" isn't known. I new that I ave
> > to include the script-tag. I tried to put it in the xml-File or the
> > html-File of my GWT2.0 project, but it doesn't work, Does anyone know
> > who to setup my project to use the Google Maps API V3 with JSNI???
> > I hope someone could help me...
> > Thank's a lot
> > Regards, Joe
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>

Jeff Schnitzer

unread,
Mar 25, 2010, 11:23:05 PM3/25/10
to google-we...@googlegroups.com
I stumbled across this while doing a related search... if you haven't
already figured it out, your problem is that in JSNI you need to call:

new $wnd.google.maps.LatLng(...)

not:

new google.maps.LatLng(...)

There's also a basic-but-functional GWT wrapper for maps v3 at
http://code.google.com/p/gwt-maps3/. It might get abandoned if that
other project matures, however.

Jeff

> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages