Search in sources :

Example 1 with LWmsLayer

use of org.vaadin.addon.leaflet.LWmsLayer in project v-leaflet by mstahv.

the class CustomProjection method getTestComponent.

@Override
public Component getTestComponent() {
    LMap leafletMap = new LMap();
    LWmsLayer lWmsLayer = new LWmsLayer();
    lWmsLayer.setUrl("http://osm.omniscale.net/proxy/service");
    lWmsLayer.setLayers("osm");
    lWmsLayer.setFormat("image/png");
    // Toggle this line to see if WMS layer is requested with differen
    // CRS
    lWmsLayer.setCrs(Crs.EPSG4326);
    leafletMap.addLayer(lWmsLayer);
    leafletMap.setCenter(52.51739, 13.40209);
    leafletMap.setZoomLevel(14);
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LWmsLayer(org.vaadin.addon.leaflet.LWmsLayer)

Example 2 with LWmsLayer

use of org.vaadin.addon.leaflet.LWmsLayer 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

LMap (org.vaadin.addon.leaflet.LMap)2 LWmsLayer (org.vaadin.addon.leaflet.LWmsLayer)2 ExternalResource (com.vaadin.server.ExternalResource)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 LImageOverlay (org.vaadin.addon.leaflet.LImageOverlay)1 LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)1 LTileLayer (org.vaadin.addon.leaflet.LTileLayer)1 Bounds (org.vaadin.addon.leaflet.shared.Bounds)1 Point (org.vaadin.addon.leaflet.shared.Point)1