Search in sources :

Example 11 with LMarker

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

the class FontawesomeMarkerAndSVGInMarker 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);
    lMarker.setIcon(FontAwesome.BEER);
    lMarker.setPopup("FontAwesome marker popup with anchor beer");
    lMarker.setPopupAnchor(new Point(0, -45));
    lMarker.addStyleName("beer");
    map.addComponent(lMarker);
    LCircleMarker lCircleMarker = new LCircleMarker(61, 22, 2);
    map.addComponent(lCircleMarker);
    getPage().getStyles().add(".v-leaflet-custom-svg circle {stroke: blue;}");
    LMarker lMarker2 = new LMarker(62, 23);
    String svgCode = "<svg width=\"100\" height=\"100\">\n" + "  <circle cx=\"50\" cy=\"50\" r=\"40\" stroke-width=\"4\" fill=\"yellow\" />\n" + "</svg>";
    lMarker2.setIconSize(new Point(100, 100));
    lMarker2.setIconAnchor(new Point(50, 50));
    lMarker2.setPopup("Custom svg popup with anchor");
    lMarker2.setPopupAnchor(new Point(0, -40));
    lMarker2.addStyleName("v-leaflet-custom-svg");
    lMarker2.setDivIcon(svgCode);
    lMarker2.addClickListener(new LeafletClickListener() {

        @Override
        public void onClick(LeafletClickEvent event) {
            Notification.show("Clicked " + event.getPoint().toString());
        }
    });
    map.addComponent(lMarker2);
    LCircleMarker lCircleMarker2 = new LCircleMarker(62, 23, 2);
    map.addComponent(lCircleMarker2);
    LMarker lMarker3 = new LMarker(60.1698560, 24.9383790);
    lMarker3.setIcon(FontAwesome.GOOGLE);
    lMarker3.setIconTextFill("#F00");
    lMarker3.setIconPathFill("#666");
    lMarker3.setIconPathStroke("#000");
    lMarker3.setPopup("Configurable FontAwesome marker popup with anchor");
    lMarker3.setPopupAnchor(new Point(0, -45));
    map.addComponent(lMarker3);
    LMarker svgDataUrlMarker = new LMarker(62, 24);
    // Note that styling is not easy this way as css don't hook into images
    svgDataUrlMarker.addStyleName("red");
    svgDataUrlMarker.setIcon(new ExternalResource("data:image/svg+xml;utf8," + svgMarker.replace("FILLCOLOR", "red")));
    svgDataUrlMarker.setIconSize(new Point(50, 50));
    svgDataUrlMarker.setIconAnchor(new Point(25, 50));
    map.addComponent(svgDataUrlMarker);
    map.zoomToContent();
    layout.addComponent(map);
    return layout;
}
Also used : LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) LMap(org.vaadin.addon.leaflet.LMap) LCircleMarker(org.vaadin.addon.leaflet.LCircleMarker) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) VerticalLayout(com.vaadin.ui.VerticalLayout) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener) Point(org.vaadin.addon.leaflet.shared.Point) LMarker(org.vaadin.addon.leaflet.LMarker) ExternalResource(com.vaadin.server.ExternalResource)

Example 12 with LMarker

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

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

the class RemoveMarker method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.setWidth("300px");
    leafletMap.setHeight("300px");
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(2);
    final LMarker m = new LMarker(5, 5);
    leafletMap.addComponent(m);
    Button remove = new Button("Remove marker");
    remove.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            leafletMap.removeComponent(m);
            event.getButton().setEnabled(false);
        }
    });
    return new VerticalLayout(leafletMap, remove);
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) LMarker(org.vaadin.addon.leaflet.LMarker)

Example 14 with LMarker

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

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