我有以下非常简单的代码序列,
public void onModuleLoad() {
final MapOptions myOptions = MapOptions.create();
myOptions.setZoom(14.0);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
myOptions.setCenter(LatLng.create(43.8495636,25.9552082));
GoogleMap map=GoogleMap.create(Document.get().getElementById("map_canvas"), myOptions);
LatLngBounds bounds=map.getBounds();
double b=bounds.getCenter().lat()+bounds.getCenter().lng();
}
当我评论代码的最后一行double b=....
时,地图会显示。
但是当我取消注释它时,我得到以下堆栈跟踪:
com.google.gwt.core.client.JavaScriptException: (TypeError) @com.google.maps.gwt.client.LatLngBounds::getCenter()([]): Object [object DOMWindow] has no method 'getCenter'
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:570)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:278)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.maps.gwt.client.LatLngBounds$.getCenter$(LatLngBounds.java)
at com.dianel.gps.client.DianelGPS.onModuleLoad(DianelGPS.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:405)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:679)