我遇到了gwt GoogleMaps v3.8的问题
此代码正常工作正常:
public class TestMaps implements EntryPoint {
public void onModuleLoad() {
final SimplePanel sp = new SimplePanel();
sp.setSize("460px", "320px");
AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();
options.setOtherParms("sensor=false&language=en");
Runnable callback = new Runnable() {
public void run() {
LatLng myLatLng = LatLng.create(51.5171, 0.1062);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(12.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
GoogleMap.create(sp.getElement(), myOptions);
}
};
AjaxLoader.loadApi("maps", "3", callback, options);
RootPanel.get("GoogleMapsContainer").add(sp);
}
}
如果我在TabPanel中放置地图,我会得到灰色区域:
public class TestMaps implements EntryPoint {
private final native static void resizeMap(GoogleMap map) /*-{
$wnd.google.maps.event.trigger(map, 'resize');
}-*/;
public void onModuleLoad() {
final DecoratedTabPanel dtp = new DecoratedTabPanel();
final SimplePanel sp = new SimplePanel();
sp.setSize("460px", "320px");
AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();
options.setOtherParms("sensor=false&language=en");
Runnable callback = new Runnable() {
public void run() {
LatLng myLatLng = LatLng.create(51.5171, 0.1062);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(12.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
GoogleMap map = GoogleMap.create(sp.getElement(), myOptions);
dtp.add(sp, "Tab1", false);
resizeMap(map);
map.setZoom(map.getZoom());
}
};
AjaxLoader.loadApi("maps", "3", callback, options);
RootPanel.get("GoogleMapsContainer").add(dtp);
}
}
我看到几个关于类似问题的帖子,但没有一个建议对我有用。 任何评论,建议都表示赞赏。
答案 0 :(得分:0)
我不熟悉GWT,但看起来你必须在选择标签时触发调整大小事件,而不是在添加标签时触发