Java + Google map API + GWT + 地理编码尝试 : Getting this exception at run time- compiling fine

标签 java google-app-engine google-maps gwt geocoding

我有一个使用 Google map 的 GWT 应用程序,我正在尝试创建一个使用 Googele 的 geocoder 的方法。获取地址 LatLng 的类。

这是我的代码:

Geocoder gc = new Geocoder();
    gc.getLatLng(this.testAddress, new LatLngCallback()
    {
        public void onFailure() 
        {
            System.out.println("ERROR: Could not obtain the Coordinates for address" + testAddress);
        }
        public void onSuccess(LatLng point) 
        {
            System.out.println("For Address= "+testAddress +"are Latitude: "+point.getLatitude() + "Longitude: "+ point.getLongitude());
        }

    });

它编译得很好,但在运行时抛出此异常:

06:25:09.359 [ERROR] [foodvendor] Unable to load module entry point class cs310.client.Main (see associated exception for details)

com.google.gwt.core.client.JavaScriptException: (TypeError): undefined is not a function
  at     com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
   at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
   at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
   at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
   at com.google.gwt.maps.client.impl.__GeocoderImplImpl.construct(__GeocoderImplImpl.java)
   at com.google.gwt.maps.client.geocode.Geocoder.<init>(Geocoder.java:41)
   at cs310.client.AshTestClass.<init>(AshTestClass.java:25)
   at cs310.client.Main.onModuleLoad(Main.java:37)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
   at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
   at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
   at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
   at java.lang.Thread.run(Thread.java:680)

我不确定这个异常是什么意思,有人可以帮助我理解吗?谢谢

最佳答案

您可能需要先使用 Maps.loadMapsApi(...) 加载 Maps JS API,然后您的 GWT 代码才能访问地理编码方法。

关于Java + Google map API + GWT + 地理编码尝试 : Getting this exception at run time- compiling fine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11294787/

相关文章:

google-app-engine - Objectify 不会同步存储,即使是现在

iphone - 使用谷歌账户登录

java - 使用高级正则表达式分割字符串

java - 从 Java 运行 Echo

java - 与从兄弟包访问类相关的经验法则

google-maps - 获取 v2 Google map API key

android - Google Maps Lite Mode 导致 RecyclerView 卡顿

java - 用于 Java 的进程内 SOAP 服务服务器

python - App Engine - 在运行时指定实体名称

javascript - 在 Google Maps API V3 中复制一个图标