Search in sources :

Example 11 with LOpenStreetMapLayer

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

the class ZoomToExtendPointOnly method getTestComponent.

@Override
public Component getTestComponent() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    // Getting my map.
    LMap map = new LMap();
    map.addComponent(new LOpenStreetMapLayer());
    LMarker lMarker = new LMarker(61, 22);
    map.addComponent(lMarker);
    map.zoomToContent();
    layout.addComponent(map);
    return layout;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 12 with LOpenStreetMapLayer

use of org.vaadin.addon.leaflet.LOpenStreetMapLayer 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 13 with LOpenStreetMapLayer

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

the class ContextClickOnMap method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    final LOpenStreetMapLayer lOpenStreetMapLayer = new LOpenStreetMapLayer();
    leafletMap.addLayer(lOpenStreetMapLayer);
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(2);
    LPolygon polygon = new LPolygon(new Point(0, 0), new Point(30, 30), new Point(0, 30));
    leafletMap.addLayer(polygon);
    polygon.addContextMenuListener(new LeafletContextMenuListener() {

        @Override
        public void onContextMenu(LeafletContextMenuEvent event) {
            Notification.show("CxtClick at polygon at " + event.toString());
        }
    });
    polygon.addClickListener(new LeafletClickListener() {

        @Override
        public void onClick(LeafletClickEvent event) {
            Notification.show("Std Click at polygon at " + event.toString());
        }
    });
    // prevent bubbling of events to DOM parents(like the map)
    polygon.setBubblingMouseEvents(false);
    leafletMap.addContextMenuListener(new LeafletContextMenuListener() {

        @Override
        public void onContextMenu(LeafletContextMenuEvent event) {
            Point point = event.getPoint();
            LMarker marker = new LMarker(point);
            marker.setPopup("Created by ContextClick on lOpenStreetMapLayer");
            leafletMap.addComponent(marker);
            marker.openPopup();
        }
    });
    leafletMap.addClickListener(new LeafletClickListener() {

        @Override
        public void onClick(LeafletClickEvent event) {
            if (event.getMouseEvent().getButton() == MouseEventDetails.MouseButton.LEFT) {
                Notification.show("Std Click on map at " + event.toString() + ". Use context click to add marker.");
            }
        }
    });
    return leafletMap;
}
Also used : LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) LeafletContextMenuListener(org.vaadin.addon.leaflet.LeafletContextMenuListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener) Point(org.vaadin.addon.leaflet.shared.Point) LeafletContextMenuEvent(org.vaadin.addon.leaflet.LeafletContextMenuEvent) LMarker(org.vaadin.addon.leaflet.LMarker) LPolygon(org.vaadin.addon.leaflet.LPolygon)

Example 14 with LOpenStreetMapLayer

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

the class ContinuousWorld method getTestComponent.

@Override
public Component getTestComponent() {
    LMap leafletMap = new LMap();
    LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
    // default false
    layer.setNoWrap(true);
    leafletMap.addBaseLayer(layer, "OSM");
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(0);
    // Should cross pacific ocean
    LPolyline lPolyline = new LPolyline(new Point(0, 360), new Point(0, 390));
    leafletMap.addComponent(lPolyline);
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) LPolyline(org.vaadin.addon.leaflet.LPolyline) Point(org.vaadin.addon.leaflet.shared.Point)

Example 15 with LOpenStreetMapLayer

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

the class ControlTest method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.setCenter(60.4525, 22.301);
    leafletMap.setZoomLevel(15);
    leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
    /*
		 * Using nameless api, doesn't add layers control
		 */
    // leafletMap.addLayer(baselayer);
    /*
		 * Layers control can also be removed manually
		 */
    // leafletMap.getLayersControl().remove();
    scale.setPosition(ControlPosition.topright);
    scale.setImperial(false);
    scale.setMetric(true);
    leafletMap.addControl(scale);
    /*
		 * DEFAULT CONTROLS These are on there by default, but can be customized
		 * and disabled if needed.
		 */
    LAttribution attribution = new LAttribution();
    attribution.setPrefix("Leaflet with Java in JVM");
    attribution.setPosition(ControlPosition.bottomleft);
    // attribution.setEnabled(false);
    leafletMap.addControl(attribution);
    LZoom zoom = new LZoom();
    zoom.setPosition(ControlPosition.bottomright);
    // zoom.setEnabled(false);
    leafletMap.addControl(zoom);
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) LZoom(org.vaadin.addon.leaflet.control.LZoom) LAttribution(org.vaadin.addon.leaflet.control.LAttribution)

Aggregations

LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)18 LMap (org.vaadin.addon.leaflet.LMap)15 Point (org.vaadin.addon.leaflet.shared.Point)9 VerticalLayout (com.vaadin.ui.VerticalLayout)7 LMarker (org.vaadin.addon.leaflet.LMarker)6 Bounds (org.vaadin.addon.leaflet.shared.Bounds)5 ExternalResource (com.vaadin.server.ExternalResource)3 Button (com.vaadin.ui.Button)3 LeafletMoveEndEvent (org.vaadin.addon.leaflet.LeafletMoveEndEvent)3 LeafletMoveEndListener (org.vaadin.addon.leaflet.LeafletMoveEndListener)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)2 Component (com.vaadin.ui.Component)2 Label (com.vaadin.ui.Label)2 LImageOverlay (org.vaadin.addon.leaflet.LImageOverlay)2 LLayerGroup (org.vaadin.addon.leaflet.LLayerGroup)2 LPolyline (org.vaadin.addon.leaflet.LPolyline)2 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)2 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)2 LZoom (org.vaadin.addon.leaflet.control.LZoom)2 Control (org.vaadin.addon.leaflet.shared.Control)2