use of org.vaadin.addon.leaflet.shared.Bounds in project v-leaflet by mstahv.
the class LayerGroupTest method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
leafletMap.setCenter(60.4525, 22.301);
leafletMap.setZoomLevel(15);
leafletMap.setControls(new ArrayList<Control>(Arrays.asList(Control.values())));
LPolyline leafletPolyline = null;
// Adding to layergroup
// Not creating a name -> not added to the
llg = new LLayerGroup();
// overlay controller
leafletPolyline = new LPolyline(new Point(60.45, 22.295), new Point(60.4555, 22.301), new Point(60.45, 22.307));
leafletPolyline.setColor("#FF0000");
leafletPolyline.setFill(true);
leafletPolyline.setFillColor("#FFFFFF");
leafletPolyline.addClickListener(listener);
llg.addComponent(leafletPolyline);
leafletPolyline = new LPolyline(new Point(60.45 + 0.005, 22.295 + 0.005), new Point(60.4555 + 0.005, 22.301 + 0.005), new Point(60.45 + 0.005, 22.307 + 0.005));
leafletPolyline.setColor("#FFFFFF");
leafletPolyline.setFill(true);
leafletPolyline.setFillColor("#FF0000");
leafletPolyline.addClickListener(listener);
llg.addComponent(leafletPolyline);
LCircle leafletCircle = new LCircle(60.4525 + 0.005, 22.301 + 0.005, 200);
leafletCircle.setColor("#FF0000");
llgNested = new LLayerGroup();
llgNested.addComponent(leafletCircle);
llg.addComponent(llgNested);
llg2 = new LLayerGroup();
leafletCircle = new LCircle(60.4525 - 0.005, 22.301 - 0.005, 20);
leafletCircle.setColor("#00FF00");
llg2.addComponent(leafletCircle);
leafletCircle = new LCircle(60.4525 - 0.008, 22.301 - 0.008, 20);
leafletCircle.setColor("#00FF00");
llg2.addComponent(leafletCircle);
leafletCircle = new LCircle(60.4525 - 0.011, 22.301 - 0.011, 20);
leafletCircle.setColor("#00FF00");
llg2.addComponent(leafletCircle);
leafletCircle = new LCircle(60.4525 - 0.014, 22.301 - 0.014, 20);
leafletCircle.setColor("#00FF00");
llg2.addComponent(leafletCircle);
leafletMap.addOverlay(llg, null);
leafletMap.addOverlay(llg2, "Small circles group");
leafletCircle = new LCircle(60.4525, 22.301, 300);
leafletCircle.setColor("#00FFFF");
// leafletCircle.addClickListener(listener);
leafletMap.addComponent(leafletCircle);
LMarker leafletMarker = new LMarker(60.4525, 22.301);
leafletMarker.addClickListener(listener);
leafletMap.addComponent(leafletMarker);
leafletMarker = new LMarker(60.4525, 22.301);
leafletMarker.setIcon(new ClassResource("testicon.png"));
leafletMarker.setIconSize(new Point(57, 52));
leafletMarker.setIconAnchor(new Point(57, 26));
leafletMarker.addClickListener(listener);
leafletMap.addComponent(leafletMarker);
leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
leafletMap.addClickListener(listener);
leafletMap.addMoveEndListener(new LeafletMoveEndListener() {
@Override
public void onMoveEnd(LeafletMoveEndEvent event) {
Bounds b = event.getBounds();
Notification.show(String.format("New viewport (%.4f,%.4f ; %.4f,%.4f)", b.getSouthWestLat(), b.getSouthWestLon(), b.getNorthEastLat(), b.getNorthEastLon()), Type.TRAY_NOTIFICATION);
}
});
return leafletMap;
}
use of org.vaadin.addon.leaflet.shared.Bounds in project v-leaflet by mstahv.
the class PlainImage method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap.setCrs(Crs.Simple);
ExternalResource url = new ExternalResource("https://www.dropbox.com/s/oajfgu8onqxfo0g/photo.jpg?dl=1");
// The size of this image is 3264 * 2448, scale it here to suite better
// for default zoomlevels
final Bounds bounds = new Bounds(new Point(0, 0), new Point(244.8, 326.4));
LImageOverlay imageOverlay = new LImageOverlay(url, bounds);
leafletMap.addLayer(imageOverlay);
// You can fit it directly or to another extend like here, you could also
// use multiple images on the background
leafletMap.setMaxBounds(new Bounds(new Point(0, 0), new Point(300, 500)));
// draw line from corner to corner
leafletMap.addLayer(new LPolyline(new Point(0, 0), new Point(244.8, 326.4)));
leafletMap.setMaxZoom(5);
return leafletMap;
}
use of org.vaadin.addon.leaflet.shared.Bounds in project v-leaflet by mstahv.
the class RestritedExtent method getTestComponent.
@Override
public Component getTestComponent() {
final LMap leafletMap = new LMap();
leafletMap.setHeight("300px");
leafletMap.setWidth("300px");
leafletMap.setZoomLevel(15);
// leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
Point p = new Point(60, 22);
Point p2 = new Point(61, 23);
final Bounds b = new Bounds(p, p2);
leafletMap.setMaxBounds(b);
leafletMap.zoomToExtent(b);
leafletMap.addComponent(new LPolyline(p, p2));
Button button = new Button("Move restricted extent (aka max bounds)");
button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
b.setNorthEastLat(b.getNorthEastLat() + 0.5);
b.setNorthEastLon(b.getNorthEastLon() + 0.5);
b.setSouthWestLat(b.getSouthWestLat() + 0.5);
b.setSouthWestLon(b.getSouthWestLon() + 0.5);
leafletMap.setMaxBounds(b);
leafletMap.addComponent(new LPolyline(new Point(b.getSouthWestLat(), b.getSouthWestLon()), new Point(b.getNorthEastLat(), b.getNorthEastLon())));
leafletMap.zoomToExtent(b);
}
});
return new VerticalLayout(leafletMap, button);
}
use of org.vaadin.addon.leaflet.shared.Bounds in project v-leaflet by mstahv.
the class SplitpanelIssue170 method getTestComponent.
@Override
public Component getTestComponent() {
LMap leafletMap = new LMap();
leafletMap.setSizeFull();
Bounds bounds = new Bounds();
bounds.setSouthWestLon(15.3308);
bounds.setSouthWestLat(41.1427);
bounds.setNorthEastLat(39.8847);
bounds.setNorthEastLon(16.887);
leafletMap.zoomToExtent(bounds);
leafletMap.addLayer(new LTileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"));
HorizontalSplitPanel sp = new HorizontalSplitPanel();
sp.setSizeFull();
sp.setFirstComponent(leafletMap);
sp.setSecondComponent(new Label("My Label"));
return sp;
}
use of org.vaadin.addon.leaflet.shared.Bounds in project v-leaflet by mstahv.
the class ZoomToExtendOnInitilaRender method getTestComponent.
@Override
public Component getTestComponent() {
final double[] latitude = { 44.03664d, 43.961669d, 43.859999d };
final double[] longitude = { 11.161893d, 11.129769d, 11.061234d };
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSizeFull();
// Getting my map.
LMap map = new LMap();
map.setControls(new ArrayList<Control>(Arrays.asList(Control.values())));
map.setSizeFull();
// Setting backgroud layer.
map.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
// I am here.
LMarker myPositon = new LMarker(43.894367, 11.078185);
myPositon.setVisible(true);
map.addComponent(myPositon);
// Get random other point.
int idxOther = Math.min((int) (Math.random() * 3.d), 2);
// Put other point on map.
LMarker leafletMarker = new LMarker(latitude[idxOther], longitude[idxOther]);
map.addComponent(leafletMarker);
// Build map bounds.
Point[] mapPoints = { new Point(43.894367, 11.078185), new Point(latitude[idxOther], longitude[idxOther]) };
Bounds mapBounds = new Bounds(mapPoints);
// I'm expecting to see my map with two points.
map.setCenter(mapBounds);
map.zoomToExtent(mapBounds);
layout.addComponent(map);
return layout;
}
Aggregations