layout.setSize("100%", "100%");
layout.setVisible(false);
layout.setStyleName("search_panel_inner");
// Create a SearchWidget, based upon a map's model:
final FeatureSearch searchWidget = new FeatureSearch(mapModel, true);
// What to do when the result of a search comes in?
// The DefaultSearchHandler will add all the features in the result to the given FeatureListGrid.
searchWidget.addSearchHandler(new DefaultSearchHandler(featureListGrid) {
// After the features have been added to the FeatureListGrid, make sure the tab with the grid is visible:
public void afterSearch() {
showPanel(gridPanel);
}
});
// Limit the maximum number of features that a search may produce:
searchWidget.setMaximumResultSize(20);
searchWidget.setBackgroundColor("#F0F0F0");
layout.addMember(searchWidget);
mapModel.addMapModelHandler(new MapModelHandler() {
// On map initialization: Select the countries layer in the search panel.
public void onMapModelChange(MapModelEvent event) {
VectorLayer layer = mapModel.getVectorLayers().get(0);
searchWidget.setLayer(layer);
}
});
return layout;
}