use of org.vaadin.addon.leaflet.LTileLayer 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.LTileLayer 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.LTileLayer 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.LTileLayer in project v-leaflet by mstahv.
the class HasControlTest method getBaseLayers.
private List<LayerWrapper> getBaseLayers() {
LTileLayer aer = new LTileLayer();
aer.setUrl("https://basemap.nationalmap.gov/ArcGIS/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}");
aer.setAttributionString(attrUSGS);
aer.setActive(false);
LTileLayer tf = new LTileLayer();
tf.setUrl("https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png");
tf.setAttributionString("Tiles Courtesy of <a href=\"https://www.thunderforest.com/\" target=\"_blank\">Thunderforest</a>" + " and OpenStreetMap contributors");
tf.setSubDomains("a", "b", "c");
tf.setActive(true);
return Arrays.asList(new LayerWrapper("ThunderForest Transport ", tf), new LayerWrapper("USGS Aerial", aer));
}
use of org.vaadin.addon.leaflet.LTileLayer in project v-leaflet by mstahv.
the class AddOverlayBugTest method getTestComponent.
@Override
public Component getTestComponent() {
VerticalLayout lmapContainer = new VerticalLayout();
lmapContainer.setMargin(true);
// create leaflet map
lmap = new LMap();
lmap.setCenter(40.712216, -74.22655);
lmap.setWidth("500px");
lmap.setHeight("400px");
lmapContainer.addComponent(lmap);
// base laser 1 & 2 (dummy base layers)
LOpenStreetMapLayer osm1 = new LOpenStreetMapLayer();
osm1.setActive(false);
lmap.addBaseLayer(osm1, "Base Layer 1");
LTileLayer osm2 = new LTileLayer("https://a.tile.thunderforest.com/cycle/{z}/{x}/{y}.png");
osm2.setAttributionString("© OpenStreetMap contributors. Tiles courtesy of Andy Allan");
osm2.setActive(true);
lmap.addBaseLayer(osm2, "Base Layer 2");
// BUG: after removing/adding the base layer and also existing wms layers are duplicated
Button wmsLayerRemoveAddButton = new Button("Add");
wmsLayerRemoveAddButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ExternalResource url = new ExternalResource("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg");
LImageOverlay imageOverlay = new LImageOverlay(url, new Bounds(new Point(40.712216, -74.22655), new Point(40.773941, -74.12544)));
imageOverlay.setOpacity(0.5);
imageOverlay.setAttribution("University of Texas");
lmap.addOverlay(imageOverlay, "imagelayer-" + System.currentTimeMillis());
// dummy wms layer
LWmsLayer result = new LWmsLayer();
result.setFormat("image/png");
result.setUrl("not/working/url/to/your/geoserver");
result.setLayers("layerselection");
// add new wms layer
lmap.addOverlay(result, "layer-" + System.currentTimeMillis());
}
});
lmapContainer.addComponent(wmsLayerRemoveAddButton);
return lmapContainer;
}
Aggregations