Search in sources :

Example 16 with LOpenStreetMapLayer

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

the class DynamicChanges method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
    leafletMap.addComponent(polyline);
    leafletMap.zoomToExtent(new Bounds(polyline.getPoints()));
    return leafletMap;
}
Also used : LMap(org.vaadin.addon.leaflet.LMap) LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) Bounds(org.vaadin.addon.leaflet.shared.Bounds)

Example 17 with LOpenStreetMapLayer

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

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

the class ImageLayerOnOSM method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap.addLayer(new LOpenStreetMapLayer());
    // Old map overlayed approximately over OSM map
    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");
    leafletMap.addLayer(imageOverlay);
    leafletMap.zoomToContent();
    return leafletMap;
}
Also used : LOpenStreetMapLayer(org.vaadin.addon.leaflet.LOpenStreetMapLayer) 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)

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