layout.setWidth100();
layout.setHeight100();
layout.setMembersMargin(10);
// Create a 3-column layout for buttons:
HLayout hLayout = new HLayout();
hLayout.setMembersMargin(15);
hLayout.setPadding(5);
VLayout firstColumn = new VLayout();
firstColumn.setMembersMargin(5);
VLayout secondColumn = new VLayout();
secondColumn.setMembersMargin(5);
VLayout thirdColumn = new VLayout();
thirdColumn.setMembersMargin(5);
// Map with ID mapOsm is defined in the XML configuration. (mapOsm.xml)
final MapWidget map = new MapWidget("mapOsm", "gwt-samples");
// Set a panning controller on the map:
map.setController(new PanController(map));
VLayout mapLayout = new VLayout();
mapLayout.setShowEdges(true);
mapLayout.setHeight("60%");
mapLayout.addMember(map);
// Create a button that centers the map to (0,0):
IButton centerBTN = new IButton(I18nProvider.getSampleMessages().navigationBtnPosition());
centerBTN.setWidth100();
centerBTN.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getMapModel().getMapView().setCenterPosition(new Coordinate(-10000000, 2000000));
}
});
// Create a button that translate the map:
IButton translateBTN = new IButton(I18nProvider.getSampleMessages().navigationBtnTranslate());
translateBTN.setWidth100();
translateBTN.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getMapModel().getMapView().translate(1000000, -500000);
}
});
// Create a button that applies a bounding box to zoom to:
IButton bboxBTN = new IButton(I18nProvider.getSampleMessages().navigationBtnBbox());
bboxBTN.setWidth100();
bboxBTN.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getMapModel().getMapView().applyBounds(new Bbox(1200000, 4600000, 1400000, 1400000),
ZoomOption.EXACT);
}
});
// Create a button that zooms out:
IButton zoomOutBTN = new IButton(I18nProvider.getSampleMessages().navigationBtnZoomOut());
zoomOutBTN.setWidth100();
zoomOutBTN.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getMapModel().getMapView().scale(0.5, ZoomOption.LEVEL_CHANGE);
}
});
// Create a button that zooms in:
IButton zoomInBTN = new IButton(I18nProvider.getSampleMessages().navigationBtnZoomIn());
zoomInBTN.setWidth100();
zoomInBTN.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getMapModel().getMapView().scale(2, ZoomOption.LEVEL_CHANGE);
}
});
firstColumn.addMember(zoomOutBTN);
firstColumn.addMember(zoomInBTN);
secondColumn.addMember(centerBTN);
secondColumn.addMember(translateBTN);
thirdColumn.addMember(bboxBTN);
hLayout.addMember(firstColumn);
hLayout.addMember(secondColumn);
hLayout.addMember(thirdColumn);
layout.addMember(mapLayout);
layout.addMember(hLayout);
return layout;