I'm currently trying out my first gwt app with gwt-map library. I'm having problem accessing getLatitude() and other similar methods on ClientLocation class. I'm new to gwt and needless to say JavaScriptObject
[update] I real开发者_Python百科ized that I have to include
private native ClientLocation getUser() /*-{
return $wnd.jsonData[0];
}-*/;
to access the methods. However, I'm prompted with the following error
com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot read property '0' of undefined stack: TypeError: Cannot read property '0' of undefined
after executing
ClientLocation user = getUser();
How should I create an instance for ClientLocation ? Any help or ideas will be much appreciated...
gwt-map Library: http://code.google.com/p/gwt-google-apis/wiki/MapsGettingStarted
API for ClientLocation: http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/com/google/gwt/ajaxloader/client/ClientLocation.html
That TypeError
you're seeing is JavaScript's equivalent to a NullPointerException
. It's likely that the jsonData
property is not defined on the host window. You can verify this by using the Chrome developer tools console or FireBug's console to evaluate window.jsonData
to ensure that it is defined.
Figured it out..
ClientLocation user = AjaxLoader.getClientLocation();
Hope this will help other first timers with gwt and gwt-map
精彩评论