Search in sources :

Example 6 with LOpenStreetMapLayer

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

the class ReadOnlyTest method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.setCenter(60.4525, 22.301);
    leafletMap.setZoomLevel(10);
    LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
    leafletMap.addBaseLayer(layer, "OSM");
    leafletMap.addControl(new LZoom());
    leafletMap.setReadOnly(true);
    Button getStates = new Button("getStates", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            StringBuilder sb = new StringBuilder("\nisDraggingEnabled() = ").append(leafletMap.isDraggingEnabled()).append("\nisBooxZoomEnabled() = ").append(leafletMap.isBoxZoomEnabled());
            Notification.show("States", sb.toString(), Type.HUMANIZED_MESSAGE);
        }
    });
    Button toggleReadOnly = new Button("toggle readonly", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            leafletMap.setReadOnly(!leafletMap.isReadOnly());
        }
    });
    VerticalLayout verticalLayout = new VerticalLayout(leafletMap, new HorizontalLayout(getStates, toggleReadOnly));
    verticalLayout.setSizeFull();
    verticalLayout.setExpandRatio(leafletMap, 1);
    return verticalLayout;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) Button(com.vaadin.ui.Button) LZoom(org.vaadin.addon.leaflet.control.LZoom) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 7 with LOpenStreetMapLayer

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

the class SizeChangeInWindow method getTestComponent.

@Override
public Component getTestComponent() {
    final LMap map = new LMap();
    map.setCenter(50.06465, 19.94498);
    map.addBaseLayer(new LOpenStreetMapLayer(), "OpenStreetMap");
    map.setSizeFull();
    Window window = new Window("Map window");
    window.setContent(map);
    window.setWidth("300px");
    window.setHeight("300px");
    getUI().addWindow(window);
    return new Label("Use the window...");
}
Also used : Window(com.vaadin.ui.Window) LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) Label(com.vaadin.ui.Label)

Example 8 with LOpenStreetMapLayer

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

the class TextOnMap method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.addLayer(new LOpenStreetMapLayer());
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(2);
    LMarker m = new LMarker(0, 0);
    // <- this becomes's to div icon's class names
    m.setStyleName("mycustomclassname");
    m.setDivIcon("Hello <strong>world</strong>!");
    // define the size for the html box
    m.setIconSize(new Point(80, 20));
    leafletMap.addLayer(m);
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) Point(org.vaadin.addon.leaflet.shared.Point) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 9 with LOpenStreetMapLayer

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

the class ZoomLimitTest method getTestComponent.

@Override
public Component getTestComponent() {
    LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
    leafletMap.addBaseLayer(layer, "OSM");
    leafletMap.setCenter(42.3625, -71.112);
    leafletMap.setZoomLevel(15);
    leafletMap.setMinZoom(MIN_ZOOM_LEVEL);
    leafletMap.setMaxZoom(MAX_ZOOM_LEVEL);
    leafletMap.addMoveEndListener(new LeafletMoveEndListener() {

        @Override
        public void onMoveEnd(LeafletMoveEndEvent event) {
            updateZoomLabel();
        }
    });
    return leafletMap;
}
Also used : LeafletMoveEndListener(org.vaadin.addon.leaflet.LeafletMoveEndListener) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) LeafletMoveEndEvent(org.vaadin.addon.leaflet.LeafletMoveEndEvent)

Example 10 with LOpenStreetMapLayer

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

the class ZoomToExtendOnInitilaRender method getTestComponent.

@Override
public Component getTestComponent() {
    final double[] latitude = { 44.03664d, 43.961669d, 43.859999d };
    final double[] longitude = { 11.161893d, 11.129769d, 11.061234d };
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    // Getting my map.
    LMap map = new LMap();
    map.setControls(new ArrayList<Control>(Arrays.asList(Control.values())));
    map.setSizeFull();
    // Setting backgroud layer.
    map.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
    // I am here.
    LMarker myPositon = new LMarker(43.894367, 11.078185);
    myPositon.setVisible(true);
    map.addComponent(myPositon);
    // Get random other point.
    int idxOther = Math.min((int) (Math.random() * 3.d), 2);
    // Put other point on map.
    LMarker leafletMarker = new LMarker(latitude[idxOther], longitude[idxOther]);
    map.addComponent(leafletMarker);
    // Build map bounds.
    Point[] mapPoints = { new Point(43.894367, 11.078185), new Point(latitude[idxOther], longitude[idxOther]) };
    Bounds mapBounds = new Bounds(mapPoints);
    // I'm expecting to see my map with two points.
    map.setCenter(mapBounds);
    map.zoomToExtent(mapBounds);
    layout.addComponent(map);
    return layout;
}
Also used : Control(org.vaadin.addon.leaflet.shared.Control) LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) Bounds(org.vaadin.addon.leaflet.shared.Bounds) VerticalLayout(com.vaadin.ui.VerticalLayout) Point(org.vaadin.addon.leaflet.shared.Point) LMarker(org.vaadin.addon.leaflet.LMarker) Point(org.vaadin.addon.leaflet.shared.Point)

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