GWT错误:java.lang.RuntimeException:'com.google.gwt.maps.client.impl.MapImpl'的延迟绑定失败

时间:2011-03-14 11:07:49

标签: java gwt gwt2

我收到了错误...

java.lang.RuntimeException: Deferred binding failed for 'com.google.gwt.maps.client.impl.MapImpl' (did you forget to inherit a
required module?).......Caused by: java.lang.IncompatibleClassChangeError: Found interface
com.google.gwt.core.ext.typeinfo.JClassType, but class was expected.....

我在Java Build Path中包含了gwt-maps.jar,并将以下内容添加到我的.gwt.xml文件中:

inherits name="com.google.gwt.maps.GoogleMaps" and <br>
script src="http://maps.google.com/maps?gwt=1&amp;file=api&amp;v=2&amp;sensor=false" 

我的源代码如下:

package com.mymaps.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.InfoWindow;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
//import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.RootPanel;

public class GWTMaps implements EntryPoint
{
    private MapWidget mapdd;

    public void onModuleLoad()
    {
        LatLng somewhereInTexas = LatLng.newInstance(30.000, -97.000);

        mapdd = new MapWidget(somewhereInTexas, 2);
        //map = new MapWidget();
        mapdd.setSize("500px", "500px");
        mapdd.addControl(new LargeMapControl());

        //final Marker marker = new Marker(somewhereInTexas);
        //mapdd.addOverlay(marker);

        final InfoWindow infoWin = mapdd.getInfoWindow();
        infoWin.open(mapdd.getCenter(), new InfoWindowContent("Deep in Texas..."));

        /*Timer t = new Timer()
        {
            public void run()
            {
                LatLng newAddress = LatLng.newInstance(18.000, 10.000);
                infoWin.close();
                marker.setVisible(false);
                marker.setLatLng(newAddress);
                marker.setVisible(true);
                map.getInfoWindow().open(newAddress, new InfoWindowContent("Somewhere in Africa..."));
                map.panTo(newAddress);
            }
        };

        t.schedule(6000);*/

        RootPanel.get("mapsTutorial").add(mapdd);
    }
}

1 个答案:

答案 0 :(得分:3)

这是gwt-google-apis的已知问题。引用相关的issue

  

存在二元不兼容性   引入GWT 2.2引起的   链接二进制时的问题   用旧GWT编译的罐子   分布。

     

解决方法是使用较旧的   GWT的版本或重新编译   gwt-maps.jar来源。

或者,您可以使用评论者提供的其中一个罐子甚至the following method provided by Matt Mastracci