Search in sources :

Example 1 with LImageOverlay

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

the class PlainImage method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap.setCrs(Crs.Simple);
    ExternalResource url = new ExternalResource("https://www.dropbox.com/s/oajfgu8onqxfo0g/photo.jpg?dl=1");
    // The size of this image is 3264 * 2448, scale it here to suite better
    // for default zoomlevels
    final Bounds bounds = new Bounds(new Point(0, 0), new Point(244.8, 326.4));
    LImageOverlay imageOverlay = new LImageOverlay(url, bounds);
    leafletMap.addLayer(imageOverlay);
    // You can fit it directly or to another extend like here, you could also
    // use multiple images on the background
    leafletMap.setMaxBounds(new Bounds(new Point(0, 0), new Point(300, 500)));
    // draw line from corner to corner
    leafletMap.addLayer(new LPolyline(new Point(0, 0), new Point(244.8, 326.4)));
    leafletMap.setMaxZoom(5);
    return leafletMap;
}
Also used : LPolyline(org.vaadin.addon.leaflet.LPolyline) 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)

Example 2 with LImageOverlay

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

Example 3 with LImageOverlay

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

the class ImageLayerOnOSM method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap.addLayer(new LOpenStreetMapLayer());
    // Old map overlayed approximately over OSM map
    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");
    leafletMap.addLayer(imageOverlay);
    leafletMap.zoomToContent();
    return leafletMap;
}
Also used : LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) 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)

Aggregations

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