Search in sources :

Example 6 with LeafletClickEvent

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

Aggregations

LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)6 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)6 LMap (org.vaadin.addon.leaflet.LMap)5 LMarker (org.vaadin.addon.leaflet.LMarker)4 Point (org.vaadin.addon.leaflet.shared.Point)4 ExternalResource (com.vaadin.server.ExternalResource)2 LOpenStreetMapLayer (org.vaadin.addon.leaflet.LOpenStreetMapLayer)2 LPolygon (org.vaadin.addon.leaflet.LPolygon)2 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 FeatureCollection (org.geotools.feature.FeatureCollection)1 FeatureIterator (org.geotools.feature.FeatureIterator)1 FeatureJSON (org.geotools.geojson.feature.FeatureJSON)1 Feature (org.opengis.feature.Feature)1 AbstractLeafletVector (org.vaadin.addon.leaflet.AbstractLeafletVector)1 LCircleMarker (org.vaadin.addon.leaflet.LCircleMarker)1 LPolyline (org.vaadin.addon.leaflet.LPolyline)1