Search in sources :

Example 6 with LPolyline

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

the class OnePointLineAndZoomToContent method test.

@Test
public void test() {
    LMap lMap = new LMap();
    lMap.addComponent(new LPolyline(new Point(0, 0)));
    lMap.zoomToContent();
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LPolyline(org.vaadin.addon.leaflet.LPolyline) Point(org.vaadin.addon.leaflet.shared.Point) Test(org.junit.Test)

Example 7 with LPolyline

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

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

the class PopupTest method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    // leafletMap.addLayer(new LOpenStreetMapLayer());
    leafletMap.setCenter(60.4525, 22.301);
    leafletMap.setZoomLevel(15);
    lMarker = new LMarker(60.4525, 22.301);
    lMarker.setPopup("Popup tied to marker");
    leafletMap.addComponent(lMarker);
    lMarker.openPopup();
    lMarker2 = new LMarker(60.4533, 22.309);
    lMarker2.setPopup("Popup tied to marker with...<br/> max height 20");
    PopupState popupState1 = new PopupState();
    popupState1.maxHeight = 20;
    lMarker2.setPopupState(popupState1);
    leafletMap.addComponent(lMarker2);
    lMarker2.openPopup();
    LPolyline lPolyline = new LPolyline(new Point(60.4525, 22.301), new Point(60.4539, 22.309));
    lPolyline.setPopup("Popup tied to polyline");
    leafletMap.addComponent(lPolyline);
    lPolyline.openPopup();
    LPopup lPopup = new LPopup(60.4525, 22.301).setContent("Hi, can't close me!");
    lPopup.setStyleName("jorma");
    leafletMap.addComponent(lPopup);
    lPopup.addDetachListener(this);
    LPopup lPopup2 = new LPopup(60.4540, 22.291).setContent("Hi, my max height ..<br/> is 30");
    PopupState popupState2 = new PopupState();
    popupState2.maxHeight = 30;
    lPopup2.setPopupState(popupState2);
    leafletMap.addComponent(lPopup2);
    lPopup.addClickListener(new LeafletClickListener() {

        @Override
        public void onClick(LeafletClickEvent event) {
            Notification.show("Jorma was clicked at a Popup anchored to " + event.getPoint() + " XY:" + event.getClientX() + " " + event.getClientY());
        }
    });
    popups.add(lPopup);
    return leafletMap;
}
Also used : LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) LMap(org.vaadin.addon.leaflet.LMap) LPolyline(org.vaadin.addon.leaflet.LPolyline) PopupState(org.vaadin.addon.leaflet.shared.PopupState) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener) Point(org.vaadin.addon.leaflet.shared.Point) LPopup(org.vaadin.addon.leaflet.LPopup) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 9 with LPolyline

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

the class VectorPerfotest method getTestComponent.

@Override
public Component getTestComponent() {
    final LMap leafletMap = new LMap();
    leafletMap.setHeight("300px");
    leafletMap.setWidth("300px");
    leafletMap.setZoomLevel(15);
    // leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
    final Random r = new Random();
    List<Point> pa = new ArrayList<Point>();
    for (int i = 0; i < 10; i++) {
        pa.add(new Point(60 + r.nextDouble() * 10, 20 + r.nextDouble() * 10));
    }
    for (int i = 0; i < 1000; i++) {
        Collections.shuffle(pa);
        LPolyline pl = new LPolyline(pa.toArray(new Point[pa.size()]));
        leafletMap.addComponent(pl);
    }
    Button button = new Button("Move restricted extent (aka max bounds)");
    button.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
        }
    });
    leafletMap.zoomToContent();
    return new VerticalLayout(leafletMap, button);
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) Random(java.util.Random) LPolyline(org.vaadin.addon.leaflet.LPolyline) Button(com.vaadin.ui.Button) ArrayList(java.util.ArrayList) VerticalLayout(com.vaadin.ui.VerticalLayout) Point(org.vaadin.addon.leaflet.shared.Point) Point(org.vaadin.addon.leaflet.shared.Point)

Example 10 with LPolyline

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

the class VectorsWithNullPoints method getTestComponent.

public Component getTestComponent() {
    leafletMap = new LMap();
    LPolygon polygon = new LPolygon(new Point(0, 0), null, new Point(1, 1), new Point(2, 3), new Point(0, 0));
    polygon.sanitizeGeometry();
    LPolyline polyline = new LPolyline();
    LPolyline polylineWithNullPoint = new LPolyline(new Point(0, 0), null, new Point(1, 1), new Point(2, 3));
    polylineWithNullPoint.sanitizeGeometry();
    LMarker m = new LMarker(0, 0);
    leafletMap.setZoomLevel(0);
    leafletMap.addComponents(polygon, polyline, polylineWithNullPoint, m);
    leafletMap.zoomToContent();
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LPolyline(org.vaadin.addon.leaflet.LPolyline) Point(org.vaadin.addon.leaflet.shared.Point) LMarker(org.vaadin.addon.leaflet.LMarker) LPolygon(org.vaadin.addon.leaflet.LPolygon)

Aggregations

LPolyline (org.vaadin.addon.leaflet.LPolyline)10 Point (org.vaadin.addon.leaflet.shared.Point)10 LMap (org.vaadin.addon.leaflet.LMap)8 Button (com.vaadin.ui.Button)3 LMarker (org.vaadin.addon.leaflet.LMarker)3 Bounds (org.vaadin.addon.leaflet.shared.Bounds)3 VerticalLayout (com.vaadin.ui.VerticalLayout)2 LLayerGroup (org.vaadin.addon.leaflet.LLayerGroup)2 LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)2 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)2 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)2 HasValue (com.vaadin.data.HasValue)1 ClassResource (com.vaadin.server.ClassResource)1 ExternalResource (com.vaadin.server.ExternalResource)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 CheckBox (com.vaadin.ui.CheckBox)1 Component (com.vaadin.ui.Component)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1