public Canvas getViewPanel() {
VLayout layout = new VLayout();
layout.setWidth100();
layout.setHeight100();
final MapWidget map = new MapWidget("mapOsm", "gwt-samples");
map.setController(new PanController(map));
final Toolbar toolbar = new Toolbar(map);
toolbar.setButtonSize(Toolbar.BUTTON_SIZE_BIG);
// Create a custom controller that will be enabled/disabled by a button in the toolbar:
final GraphicsController customController = new AbstractGraphicsController(map) {
public void onMouseUp(MouseUpEvent event) {
Coordinate screenPosition = getScreenPosition(event);
Coordinate worldPosition = getWorldPosition(event);
SC.say(I18nProvider.getSampleMessages().customControllerScreenCoordinates() + " = " + screenPosition
+ "<br/>" + I18nProvider.getSampleMessages().customControllerWorldCoordinates() + " = "
+ worldPosition);
}
};
// Add the customController to the toolbar using a custom ToolbarModalAction button
toolbar.addModalButton(new ToolbarModalAction("[ISOMORPHIC]/geomajas/widget/target.gif", I18nProvider
.getSampleMessages().customToolbarToolsTooltip()) {
@Override
public void onSelect(ClickEvent event) {
map.setController(customController);
}
@Override
public void onDeselect(ClickEvent event) {
map.setController(null);
}
});
layout.addMember(toolbar);
layout.addMember(map);