layout.setMargin(10);
// ---------------------------------------------------------------------
// Create the left-side (map and tabs):
// ---------------------------------------------------------------------
final MapWidget map = new MapWidget("mapMain", "app");
final Toolbar toolbar = new Toolbar(map);
toolbar.setButtonSize(Toolbar.BUTTON_SIZE_BIG);
toolbar.setBackgroundColor("#647386");
toolbar.setBackgroundImage("");
toolbar.setBorder("0px");
map.getMapModel().addMapModelHandler(new MapModelHandler() {
public void onMapModelChange(MapModelEvent event) {
Label title = new Label("Geomajas GWT: hello world");
title.setStyleName("appTitle");
title.setWidth(260);
toolbar.addFill();
toolbar.addMember(title);
GetMapImageAction getMapImage = new GetMapImageAction(map);
toolbar.addSeparator();
toolbar.addActionButton(getMapImage);
GetLegendImageAction getLegendImageAll = new GetLegendImageAction(map, true);
toolbar.addSeparator();
toolbar.addActionButton(getLegendImageAll);
GetLegendImageAction getLegendImage = new GetLegendImageAction(map, false);
toolbar.addSeparator();
toolbar.addActionButton(getLegendImage);
// switch all labels on
for (Layer layer : map.getMapModel().getLayers()) {
layer.setLabeled(true);
}
}
});
map.getMapModel().addLayerSelectionHandler(new LayerSelectionHandler() {
public void onSelectLayer(LayerSelectedEvent event) {
for (Layer layer : map.getMapModel().getLayers()) {
if (layer.isSelected()) {
layer.setVisible(true);
} else {
layer.setVisible(false);
}
}
}
public void onDeselectLayer(LayerDeselectedEvent event) {
}
});
VLayout mapLayout = new VLayout();
mapLayout.addMember(toolbar);
mapLayout.addMember(map);
mapLayout.setHeight("65%");
VLayout leftLayout = new VLayout();
leftLayout.setBorder("10px solid #777777");
leftLayout.setStyleName("round_corner");
leftLayout.addMember(mapLayout);
layout.addMember(leftLayout);
// Add a search panel to the top-right of the map:
SearchPanel searchPanel = new SearchPanel(map.getMapModel(), mapLayout);
mapLayout.addChild(searchPanel);
// ---------------------------------------------------------------------
// Create the right-side (overview map, layer-tree, legend):
// ---------------------------------------------------------------------
final SectionStack sectionStack = new SectionStack();
sectionStack.setBorder("10px solid #777777");
sectionStack.setStyleName("round_corner");
sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
sectionStack.setCanReorderSections(true);
sectionStack.setCanResizeSections(false);
sectionStack.setSize("250px", "100%");
// Overview map layout:
SectionStackSection section1 = new SectionStackSection("Overview map");
section1.setExpanded(true);
overviewMap = new OverviewMap("mapOverview", "app", map, false, true);
overviewMap.setTargetMaxExtentRectangleStyle(new ShapeStyle("#888888", 0.3f, "#666666", 0.75f, 2));
overviewMap.setRectangleStyle(new ShapeStyle("#6699FF", 0.3f, "#6699CC", 1f, 2));
section1.addItem(overviewMap);
sectionStack.addSection(section1);
// LayerTree layout:
SectionStackSection section2 = new SectionStackSection("Layer tree");
section2.setExpanded(true);
LayerTree layerTree = new LayerTree(map);
section2.addItem(layerTree);
sectionStack.addSection(section2);
// Legend layout:
SectionStackSection section3 = new SectionStackSection("Legend");
section3.setExpanded(true);
legend = new Legend(map.getMapModel());
legend.setBackgroundColor("#FFFFFF");
section3.addItem(legend);
sectionStack.addSection(section3);
// Putting the right side layouts together: