// Create map with OSM layer, and add a PanController to it:
VLayout mapLayout = new VLayout();
mapLayout.setShowEdges(true);
mapLayout.setHeight("60%");
final MapWidget map = new MapWidget("mapOsm", "gwt-samples");
map.setController(new PanController(map));
mapLayout.addMember(map);
// Create a button layout:
HLayout buttonLayout = new HLayout();
buttonLayout.setHeight(25);
buttonLayout.setMembersMargin(10);
IButton button1 = new IButton(I18nProvider.getSampleMessages().screenWorldBTNScreen());
button1.setWidth("50%");
final Image screenImage = new Image("imageInScreenSpace");
screenImage.setHref(Geomajas.getIsomorphicDir() + "geomajas/example/images/smile.png");
screenImage.setBounds(new Bbox(60, 60, 48, 48)); // Pixel coordinates
screenImage.setStyle(new PictureStyle(0.6));
button1.addClickHandler(new ClickHandler() {
// Draw an image in screen space:
public void onClick(ClickEvent event) {
map.render(screenImage, RenderGroup.SCREEN, RenderStatus.ALL);
}
});
buttonLayout.addMember(button1);
IButton button2 = new IButton(I18nProvider.getSampleMessages().screenWorldBTNWorld());
button2.setWidth("50%");
// An image
final Image worldImage = new Image("imageInWorldSpace");
worldImage.setHref(Geomajas.getIsomorphicDir() + "geomajas/example/images/smile.png");
worldImage.setBounds(new Bbox(-2000000, -2000000, 4000000, 4000000)); // Mercator coordinates
worldImage.setStyle(new PictureStyle(0.8));
// And some geometries
final GfxGeometry worldGeometry = new GfxGeometry("MultiPolygonInWorldSpace");
final GeometryFactory gf = new GeometryFactory(map.getMapModel().getSrid(), map.getMapModel().getPrecision());
Polygon p1 = gf.createPolygon(gf.createLinearRing(new Bbox(10000000d, 1000d, 1000000d, 1000000d)), null);
Polygon p2 = gf.createPolygon(gf.createLinearRing(new Bbox(12000000d, 1000d, 500000d, 500000d)), null);
MultiPolygon mp = gf.createMultiPolygon(new Polygon[] {p1, p2});
worldGeometry.setStyle(new ShapeStyle("#FF0000", 0.5f, "#FF0000", 1.0f, 2));
worldGeometry.setGeometry(mp);
final GfxGeometry worldGeometry2 = new GfxGeometry("MultiPointInWorldSpace");
SymbolInfo si = new SymbolInfo();
CircleInfo ci = new CircleInfo();
ci.setR(8.0f);
si.setCircle(ci);
Point pt1 = gf.createPoint(new Coordinate(6000000, -5000000));
Point pt2 = gf.createPoint(new Coordinate(8000000, -5000000));
Point pt3 = gf.createPoint(new Coordinate(7000000, -7000000));
worldGeometry2.setStyle(new ShapeStyle("#0000FF", 0.3f, "#0000FF", 1.0f, 2));
worldGeometry2.setGeometry(gf.createMultiPoint(new Point[] {pt1, pt2, pt3}));
worldGeometry2.setSymbolInfo(si);
button2.addClickHandler(new ClickHandler() {
// Draw an image and some geometries in world space:
public void onClick(ClickEvent event) {
map.registerWorldPaintable(worldImage);
map.registerWorldPaintable(worldGeometry);
map.registerWorldPaintable(worldGeometry2);
}
});
buttonLayout.addMember(button2);
// Create a second button layout (delete buttons):
HLayout buttonLayout2 = new HLayout();
buttonLayout2.setMembersMargin(10);
IButton button3 = new IButton(I18nProvider.getSampleMessages().screenWorldBTNScreenDelete());
button3.setWidth("50%");
button3.addClickHandler(new ClickHandler() {
// Delete the image in screen space:
public void onClick(ClickEvent event) {
map.render(screenImage, RenderGroup.SCREEN, RenderStatus.DELETE);
}
});
buttonLayout2.addMember(button3);
IButton button4 = new IButton(I18nProvider.getSampleMessages().screenWorldBTNWorldDelete());
button4.setWidth("50%");
button4.addClickHandler(new ClickHandler() {
// Delete the image and geometries in world space:
public void onClick(ClickEvent event) {
map.unregisterWorldPaintable(worldImage);
map.unregisterWorldPaintable(worldGeometry);
map.unregisterWorldPaintable(worldGeometry2);
}
});
buttonLayout2.addMember(button4);
// Place both in the layout: