Search in sources :

Example 6 with LTileLayer

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;
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker) LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) AbstractTest(org.vaadin.addonhelpers.AbstractTest) DetailsGenerator(com.vaadin.ui.components.grid.DetailsGenerator) Component(com.vaadin.ui.Component) Grid(com.vaadin.ui.Grid) ItemClickListener(com.vaadin.ui.components.grid.ItemClickListener) LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) Grid(com.vaadin.ui.Grid) VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 7 with LTileLayer

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;
}
Also used : LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener) Point(org.vaadin.addon.leaflet.shared.Point) LMarker(org.vaadin.addon.leaflet.LMarker) ExternalResource(com.vaadin.server.ExternalResource)

Example 8 with LTileLayer

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;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) Bounds(org.vaadin.addon.leaflet.shared.Bounds) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) Label(com.vaadin.ui.Label)

Example 9 with LTileLayer

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>" + "&nbspand OpenStreetMap contributors");
    tf.setSubDomains("a", "b", "c");
    tf.setActive(true);
    return Arrays.asList(new LayerWrapper("ThunderForest Transport ", tf), new LayerWrapper("USGS Aerial", aer));
}
Also used : LTileLayer(org.vaadin.addon.leaflet.LTileLayer)

Example 10 with LTileLayer

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;
}
Also used : LTileLayer(org.vaadin.addon.leaflet.LTileLayer) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) ClickEvent(com.vaadin.ui.Button.ClickEvent) Bounds(org.vaadin.addon.leaflet.shared.Bounds) Point(org.vaadin.addon.leaflet.shared.Point) ExternalResource(com.vaadin.server.ExternalResource) LImageOverlay(org.vaadin.addon.leaflet.LImageOverlay) LMap(org.vaadin.addon.leaflet.LMap) Button(com.vaadin.ui.Button) LWmsLayer(org.vaadin.addon.leaflet.LWmsLayer) VerticalLayout(com.vaadin.ui.VerticalLayout)

Aggregations

LTileLayer (org.vaadin.addon.leaflet.LTileLayer)13 LMap (org.vaadin.addon.leaflet.LMap)7 Point (org.vaadin.addon.leaflet.shared.Point)3 ExternalResource (com.vaadin.server.ExternalResource)2 Button (com.vaadin.ui.Button)2 ClickEvent (com.vaadin.ui.Button.ClickEvent)2 Component (com.vaadin.ui.Component)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 LLayerGroup (org.vaadin.addon.leaflet.LLayerGroup)2 LMarker (org.vaadin.addon.leaflet.LMarker)2 LWmsLayer (org.vaadin.addon.leaflet.LWmsLayer)2 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)2 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)2 Bounds (org.vaadin.addon.leaflet.shared.Bounds)2 HasValue (com.vaadin.data.HasValue)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 CheckBox (com.vaadin.ui.CheckBox)1 Grid (com.vaadin.ui.Grid)1 HorizontalSplitPanel (com.vaadin.ui.HorizontalSplitPanel)1 Label (com.vaadin.ui.Label)1