我正在使用 GWt 和Google Maps API V3。我能够在覆盖自定义形状的简单面板内渲染地图。如果提供了新查询,我想清除面板并再次呈现地图。
public ResultsPanel(ScolopaxController _controller,
ScolopaxConstants _constants) {
super();
controller = _controller;
layout = new SimplePanel();
paging = new HorizontalPanel();
paging.setWidth("100%");
paging.setSpacing(0);
layout.add(paging);
this.setWidget(paging);
}
//After processing the values in the server this method is called
public void setPlots(PlotSetOutput result) {
this.page = 1;
this.loadMapApi(result);
controller.getScolopaxGUI().addResultsTab();
}
private void loadMapApi(final PlotSetOutput result) {
paging.clear(); // does not work
// load all the libs for use in the maps
ArrayList<LoadLibrary> loadLibraries = new ArrayList<LoadApi.LoadLibrary>();
loadLibraries.add(LoadLibrary.ADSENSE);
loadLibraries.add(LoadLibrary.DRAWING);
loadLibraries.add(LoadLibrary.GEOMETRY);
loadLibraries.add(LoadLibrary.PANORAMIO);
loadLibraries.add(LoadLibrary.PLACES);
loadLibraries.add(LoadLibrary.WEATHER);
loadLibraries.add(LoadLibrary.VISUALIZATION);
Runnable onLoad = new Runnable() {
@Override
public void run() {
draw(result);
}
};
LoadApi.go(onLoad, loadLibraries, sensor);
}
private void draw(PlotSetOutput result) {
drawHeatMap(result);
}
private void addMapWidget(Widget widget) {
paging.add(widget);
}
private void drawHeatMap(PlotSetOutput result) {
displayOnMap wMap = new displayOnMap(result);
addMapWidget(wMap);
}
这是 displayOnMap 方法
private final VerticalPanel pWidget;
private MapWidget mapWidget;
private static Rectangle rectangle;
private static final LatLng USCENTER = LatLng.newInstance(33.68,-116.17);
public displayOnMap(PlotSetOutput result) {
pWidget = new VerticalPanel();
initWidget(pWidget);
draw(result);
}
private void draw(PlotSetOutput result) {
MapOptions mapOpts = MapOptions.newInstance();
mapOpts.setZoom(4);
mapOpts.setCenter(USCENTER);
mapOpts.setMapTypeId(MapTypeId.TERRAIN);
mapWidget = new MapWidget(mapOpts);
pWidget.add(mapWidget);
mapWidget.setSize("800px", "800px");
.... }
当服务器调用 SetPlots 方法时,我试图清除分页面板。我试图清除 pWidget 面板,但没有任何效果。调用第二个查询时,我的输出如下所示