Hi Paul,

You most likely want to write your JSNI call to the external
Javascript function using the $wnd scope, i.e.

public static native void initGoogleMaps() /*-{
  $wnd.initializeGoogleMaps();
}-*/;

//Adam

On 30 Maj, 20:10, Paul van Hoven <[email protected]>
wrote:
> I need some javascript in my page that can't be done by GWT.
> Therefore, i wrote some javascript and stored it in a js file. I
> tested the javascript code and it works. Then, i wanted to integrate
> the javascript into my gwt widget by using JSNI. I did this in the
> following way:
>
> JSNI method in my gwt code SearchMobileWidget:
>
> public static native void initGoogleMaps() /*-{
>   initializeGoogleMaps();
>
> }-*/;
>
> my module xml file mobile.gwt.xml (extract):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.4//
> EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-
> source/core/src/gwt-module.dtd">
> <module rename-to='mobile'>
>         ...
>         <entry-point class='parken.client.Mobile'/>
>
>         <script src="http://maps.google.com/maps?
> gwt=1&amp;file=api&amp;v=2&amp;key=ABQIAAAAX2sz-2-
> uXPNa8l3S5mcKSRRDqbgtXTigyAF4pAvrYpB7OU5BT0XF2EUW5rzHwW_BCpDPh_kGpecQ"/
>
>         <script src="googlemaps.js"/>
> </module>
>
> my javascript function "initializeGoogleMaps()" in the js file:
>
>                 function initializeGoogleMaps() {
>                         if (GBrowserIsCompatible()) {
>                                 map = new GMap2( document.getElementById( 
> "GoogleMapsDiv" ) );
>                                 //....and so on...
>                         }
>                 }
>
> Remark: If you are wondering why i don't use maps for gwt i must tell
> you that it does not work in my special case for what reason ever. But
> using google maps in the normal way with javascript it works fine.
>
> Okay, back to my problem. When i now run the gwt hosted mode browser i
> get the following error message in the console:
>
> [ERROR] Unable to load module entry point class parken.client.Mobile
> (see associated exception for details)
> com.google.gwt.core.client.JavaScriptException: (ReferenceError):
> Can't find variable: initializeGoogleMaps
> ...
> at parken.client.mobile.SearchMobileWidget.initGoogleMaps(Native
> Method)
>
> Does anybody know what i made wrong or a guess?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to