use of org.vaadin.addon.leaflet.LPolyline in project v-leaflet by mstahv.
the class LayerGroupTest method setup.
@Override
protected void setup() {
super.setup();
addMarkers = new CheckBox("Add markers");
content.addComponentAsFirst(addMarkers);
delete = new CheckBox("Delete on click");
content.addComponentAsFirst(delete);
showLayerGroupCB = new CheckBox("Show first layer (switch on/off from server side)");
showLayerGroupCB.setValue(true);
content.addComponentAsFirst(showLayerGroupCB);
showLayerGroupCB.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
@Override
public void valueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
if (!leafletMap.hasComponent(llg)) {
leafletMap.addComponent(llg);
}
} else {
leafletMap.removeComponent(llg);
}
}
});
Button button = new Button("Delete first component from map (may also be a layer containing many components)");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
for (Component c : leafletMap) {
if (!(c instanceof LTileLayer)) {
leafletMap.removeComponent(c);
break;
}
}
}
});
content.addComponentAsFirst(button);
button = new Button("Delete first component from first layer group (may also be a layer containing many components)");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
LLayerGroup group = null;
for (Component c : leafletMap) {
if (c instanceof LLayerGroup) {
group = (LLayerGroup) c;
break;
}
}
if (group.getComponentCount() > 0) {
Component next = group.iterator().next();
group.removeComponent(next);
} else {
Notification.show("No component in first component group");
}
}
});
content.addComponentAsFirst(button);
button = new Button("Add polyline to first group on map (creates if does not exist)");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
LLayerGroup group = null;
for (Component c : leafletMap) {
if (c instanceof LLayerGroup) {
group = (LLayerGroup) c;
break;
}
}
if (group == null) {
group = new LLayerGroup();
leafletMap.addOverlay(group, "new group");
}
LPolyline lPolyline = new LPolyline(new Point(60.44, 22.30), new Point(60.456, 22.304));
lPolyline.addClickListener(listener);
group.addComponent(lPolyline);
}
});
content.addComponentAsFirst(button);
}
use of org.vaadin.addon.leaflet.LPolyline 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.LPolyline 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.LPolyline 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.LPolyline in project v-leaflet by mstahv.
the class TransparentMap method getTestComponent.
@Override
public Component getTestComponent() {
Page.getCurrent().getStyles().add(".v-leaflet .leaflet-container {background: yellow;}");
leafletMap = new LMap();
leafletMap.setWidth("300px");
leafletMap.setHeight("300px");
leafletMap.setCenter(0, 0);
leafletMap.setZoomLevel(2);
LPolyline lPolyline = new LPolyline(new Point(-30, -30), new Point(0, 30), new Point(30, 0));
lPolyline.setColor("red");
lPolyline.setFill(true);
lPolyline.getStyle().setFillOpacity(1.0);
leafletMap.addLayer(lPolyline);
LCircleMarker lCircleMarker = new LCircleMarker(30, 30, 40);
lCircleMarker.getStyle().setFillOpacity(0.05);
leafletMap.addLayer(lCircleMarker);
return leafletMap;
}
Aggregations