Search in sources :

Example 6 with LMarker

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

Example 7 with LMarker

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

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

the class PointField method prepareEditing.

@Override
protected void prepareEditing(boolean userOriginatedValueChangeEvent) {
    if (marker == null) {
        marker = new LMarker(JTSUtil.toLeafletPoint(getCrsTranslator().toPresentation(getValue())));
        map.addLayer(marker);
    } else {
        marker.setPoint(JTSUtil.toLeafletPoint(getCrsTranslator().toPresentation(getValue())));
    }
    drawRegistration = marker.addDragEndListener(editDragEndListener);
    clickRegistration = map.addClickListener(editClickListener);
    map.zoomToContent();
}
Also used : LMarker(org.vaadin.addon.leaflet.LMarker)

Example 9 with LMarker

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

the class CenterAndZoomTest method doWork.

private void doWork(String... ops) {
    trayNotify("got click");
    if (marker != null) {
        map.removeComponent(marker);
        marker = null;
    }
    double lat = 36;
    double lng = -108;
    int zoom = 12;
    marker = new LMarker(lat, lng);
    StringBuilder sb = new StringBuilder();
    map.addComponent(marker);
    sb.append(" marker");
    for (String op : ops) {
        if ("c".equals(op)) {
            map.setCenter(lat, lng);
            sb.append(" center");
        } else if ("z".equals(op)) {
            map.setZoomLevel(zoom);
            sb.append(" zoom");
        } else if ("v".equals(op)) {
            map.setView(lat, lng, (double) zoom);
            // Notification.show("Not yet implemented");
            sb.append(" setView");
        }
    }
    trayNotify("Operation sequence:" + sb.toString());
}
Also used : LMarker(org.vaadin.addon.leaflet.LMarker)

Example 10 with LMarker

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

Aggregations

LMarker (org.vaadin.addon.leaflet.LMarker)14 LMap (org.vaadin.addon.leaflet.LMap)12 Point (org.vaadin.addon.leaflet.shared.Point)8 VerticalLayout (com.vaadin.ui.VerticalLayout)6 LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)6 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)4 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)4 LPolyline (org.vaadin.addon.leaflet.LPolyline)3 ExternalResource (com.vaadin.server.ExternalResource)2 Button (com.vaadin.ui.Button)2 LPolygon (org.vaadin.addon.leaflet.LPolygon)2 LTileLayer (org.vaadin.addon.leaflet.LTileLayer)2 Bounds (org.vaadin.addon.leaflet.shared.Bounds)2 Control (org.vaadin.addon.leaflet.shared.Control)2 ClassResource (com.vaadin.server.ClassResource)1 Component (com.vaadin.ui.Component)1 Grid (com.vaadin.ui.Grid)1 DetailsGenerator (com.vaadin.ui.components.grid.DetailsGenerator)1 ItemClickListener (com.vaadin.ui.components.grid.ItemClickListener)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1