use of org.vaadin.addon.leaflet.LeafletMoveEndEvent in project v-leaflet by mstahv.
the class InitialViewPortDetectionWithFixedSize method getTestComponent.
@Override
public Component getTestComponent() {
LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
leafletMap.addBaseLayer(layer, "OSM");
leafletMap.setCenter(42.3625, -71.112);
leafletMap.setZoomLevel(15);
leafletMap.addMoveEndListener(new LeafletMoveEndListener() {
@Override
public void onMoveEnd(LeafletMoveEndEvent event) {
updateZoomLabel();
}
});
return leafletMap;
}
use of org.vaadin.addon.leaflet.LeafletMoveEndEvent 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.LeafletMoveEndEvent in project v-leaflet by mstahv.
the class ZoomLimitTest method getTestComponent.
@Override
public Component getTestComponent() {
LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
leafletMap.addBaseLayer(layer, "OSM");
leafletMap.setCenter(42.3625, -71.112);
leafletMap.setZoomLevel(15);
leafletMap.setMinZoom(MIN_ZOOM_LEVEL);
leafletMap.setMaxZoom(MAX_ZOOM_LEVEL);
leafletMap.addMoveEndListener(new LeafletMoveEndListener() {
@Override
public void onMoveEnd(LeafletMoveEndEvent event) {
updateZoomLabel();
}
});
return leafletMap;
}
use of org.vaadin.addon.leaflet.LeafletMoveEndEvent in project v-leaflet by mstahv.
the class DynamicChanges method setup.
@Override
protected void setup() {
super.setup();
HorizontalLayout tools = new HorizontalLayout();
Button button = new Button("Random new point");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ArrayList<Point> arrayList = new ArrayList<Point>(Arrays.asList(polyline.getPoints()));
arrayList.add(new Point(60 + r.nextInt(10), 20 + r.nextInt(10)));
polyline.setPoints(arrayList.toArray(new Point[0]));
}
});
tools.addComponent(button);
button = new Button("Zoom to polyline");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
leafletMap.zoomToExtent(new Bounds(polyline.getPoints()));
}
});
tools.addComponent(button);
button = new Button("Center to last point ");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Point[] points = polyline.getPoints();
leafletMap.setCenter(points[points.length - 1]);
}
});
tools.addComponent(button);
button = new Button("Zoom to last point");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Point[] points = polyline.getPoints();
leafletMap.zoomToExtent(new Bounds(points[points.length - 1]));
}
});
tools.addComponent(button);
button = new Button("Show current zoom");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Double zoomLevel = leafletMap.getZoomLevel();
Notification.show("Zoomlevel is " + zoomLevel);
}
});
tools.addComponent(button);
button = new Button("Show current center point");
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Notification.show("Center point is " + leafletMap.getCenter());
}
});
tools.addComponent(button);
final LeafletMoveEndListener moveEndListener = new LeafletMoveEndListener() {
@Override
public void onMoveEnd(LeafletMoveEndEvent event) {
Notification.show("Moved or zoomed", Type.TRAY_NOTIFICATION);
}
};
final CheckBox checkBox = new CheckBox("Toggle move listener");
checkBox.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
@Override
public void valueChange(ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
registration = leafletMap.addMoveEndListener(moveEndListener);
} else if (registration != null) {
registration.remove();
}
}
});
tools.addComponent(checkBox);
content.addComponentAsFirst(tools);
}
Aggregations