2

我在使用 openlayers 和 openstreetmaps 来让一个简单的示例项目工作时遇到 gwt 问题。

当我运行项目时,它总是抛出异常:

java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406) 
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) 
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:5  26) 
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source) Caused by:   com.google.gwt.core.client.JavaScriptException: (TypeError)   @org.gwtopenmaps.openlayers.client.layer.OSMImpl::Osmarender(Ljava/lang/String;)([string:   'Osmarender']): $wnd.OpenLayers.Layer.OSM.Osmarender is not a constructor 
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:24  9) 
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) 
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571) 
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279) 
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) 
at org.gwtopenmaps.openlayers.client.layer.OSMImpl.Osmarender(OSMImpl.java) 
at org.gwtopenmaps.openlayers.client.layer.OSM.Osmarender(OSM.java:38) 
at de.iisys.sara2.sara2lightWebclient.client.View.initMap(View.java:33)
at de.iisys.sara2.sara2lightWebclient.client.View.onModuleLoad(View.java:26) ... 9 more 

我的示例代码:

public class View implements EntryPoint {

public View() {

}

public void onModuleLoad() {
    initMap();
}

private void initMap() {
    MapOptions defaultMapOptions = new MapOptions();
    MapWidget mapWidget = new MapWidget("684px", "330px", defaultMapOptions);

    OSM osm_1 = OSM.Osmarender("Osmarender");
    OSM osm_2 = OSM.Mapnik("Mapnik");
    OSM osm_3 = OSM.CycleMap("CycleMap"); 
    OSM osm_4 = OSM.Maplint("Maplint"); 

    osm_1.setIsBaseLayer(true);
    osm_2.setIsBaseLayer(true);
    osm_3.setIsBaseLayer(true);
    osm_4.setIsBaseLayer(true);

    Map map = mapWidget.getMap();
    map.addLayer(osm_1);
    map.addLayer(osm_2);
    map.addLayer(osm_3);
    map.addLayer(osm_4);
    map.addControl(new LayerSwitcher());
    map.addControl(new MousePosition());

    LonLat lonLat = new LonLat(6.95, 50.94);          
    lonLat.transform("EPSG:4326", "EPSG:900913"); 

    map.setCenter(lonLat, 12);                      

    RootPanel.get().add(mapWidget);
}

有谁知道如何解决这个问题?

4

1 回答 1

1

经过一些研究,我可以告诉你,不再支持 osmarender 和 maplint:http ://wiki.openstreetmap.org/wiki/Tiles@home

如果你从你的函数(osm_1 和 osm_4)中删除那些层,一切都会完美运行。

于 2012-12-06T21:31:22.143 回答