use of org.vaadin.addon.leaflet.LMarker 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.LMarker in project v-leaflet by mstahv.
the class MapInGridDetailsRow method getTestComponent.
@Override
public Component getTestComponent() {
VerticalLayout vl = new VerticalLayout();
vl.setSizeFull();
final Grid<String> grid = new Grid<>();
grid.setSizeFull();
// Define some columns
grid.addColumn(r -> r).setCaption("Name");
grid.addColumn(r -> "").setCaption("Born");
// Add some data rows
grid.setItems("Nicolaus Copernicus", "Galileo Galilei", "Johannes Kepler");
grid.setDetailsGenerator((DetailsGenerator<String>) s -> {
final LMap leafletMap = new LMap();
final LTileLayer baselayer = new LTileLayer();
baselayer.setAttributionString("OpenStreetMap");
baselayer.setUrl("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png");
leafletMap.addLayer(baselayer);
leafletMap.setWidth("100%");
leafletMap.setHeight("100px");
leafletMap.setZoomLevel(3);
LMarker leafletMarker = new LMarker(-21.54, 30.76);
leafletMap.addComponent(leafletMarker);
leafletMap.zoomToContent();
return leafletMap;
});
grid.addItemClickListener((ItemClickListener<String>) event -> grid.setDetailsVisible(event.getItem(), !grid.isDetailsVisible(event.getItem())));
vl.addComponent(grid);
return vl;
}
use of org.vaadin.addon.leaflet.LMarker in project v-leaflet by mstahv.
the class MarkerZIndexOffset method getTestComponent.
@Override
public Component getTestComponent() {
LMap leafletMap = new LMap();
leafletMap.setWidth("300px");
leafletMap.setHeight("300px");
leafletMap.setCenter(0, 0);
leafletMap.setZoomLevel(2);
final AtomicInteger currentBase = new AtomicInteger(1000);
final LMarker m = new LMarker(5, 5);
m.setId("5 5");
final LMarker m2 = new LMarker(9, 9);
m2.setZIndexOffset(currentBase.get());
m2.setId("9 9");
// m.setZIndexOffset(currentBase.getValue());
final LMarker m3 = new LMarker(7, 7);
leafletMap.addComponents(m, m2, m3);
Button move = new Button("Move top right on top");
move.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
m.setZIndexOffset(currentBase.get());
currentBase.addAndGet(1000);
m2.setZIndexOffset(currentBase.get());
}
});
Button move2 = new Button("Move low left to top");
move2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
m2.setZIndexOffset(currentBase.get());
currentBase.addAndGet(1000);
m.setZIndexOffset(currentBase.get());
}
});
return new VerticalLayout(leafletMap, move, move2);
}
use of org.vaadin.addon.leaflet.LMarker in project v-leaflet by mstahv.
the class SimpleMarkerTest method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
LTileLayer pk = new LTileLayer();
pk.setUrl("http://{s}.kartat.kapsi.fi/peruskartta/{z}/{x}/{y}.png");
pk.setAttributionString("Maanmittauslaitos, hosted by kartat.kapsi.fi");
pk.setMaxZoom(18);
pk.setSubDomains("tile2");
pk.setDetectRetina(true);
leafletMap.addBaseLayer(pk, "Peruskartta");
leafletMap.setCenter(60.4525, 22.301);
leafletMap.setZoomLevel(15);
lMarker = new LMarker(60.4525, 22.301);
lMarker.addStyleName("specialstyle");
lMarker.setIcon(new ExternalResource("http://leafletjs.com/examples/custom-icons/leaf-red.png"));
lMarker.setIconAnchor(new Point(22, 94));
lMarker.setPopup("Popupstring");
leafletMap.addComponent(lMarker);
lMarker.openPopup();
LMarker another = new LMarker(60.4525, 22.303);
another.addClickListener(new LeafletClickListener() {
@Override
public void onClick(LeafletClickEvent event) {
Notification.show("Another marker was clicke.");
}
});
leafletMap.addComponent(another);
return leafletMap;
}
use of org.vaadin.addon.leaflet.LMarker in project v-leaflet by mstahv.
the class TextOnMap method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
leafletMap.addLayer(new LOpenStreetMapLayer());
leafletMap.setCenter(0, 0);
leafletMap.setZoomLevel(2);
LMarker m = new LMarker(0, 0);
// <- this becomes's to div icon's class names
m.setStyleName("mycustomclassname");
m.setDivIcon("Hello <strong>world</strong>!");
// define the size for the html box
m.setIconSize(new Point(80, 20));
leafletMap.addLayer(m);
return leafletMap;
}
Aggregations