开发者

GWT ERROR: java.lang.RuntimeException: Deferred binding failed for 'com.google.gwt.maps.client.impl.MapImpl'

I am getting the error...

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.....

I have included gwt-maps.jar in the Java Build Path and added the following to my .gwt.xml file:

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" 

My source code is given below.

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);
    }
}


It is a known issue with gwt-google-apis. Quote from the relevant issue :

There is a binary incompatibility introduced in GWT 2.2 which causes problems when linking against binary jars compiled with older GWT distributions.

The workarounds are to use an older version of GWT or to re-compile gwt-maps.jar from source.

Alternatively, you might be able to use one of the jars provided by the commenters or even the following method provided by Matt Mastracci

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜