Search in sources :

Example 1 with LPopup

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

the class PopupTest method setup.

@Override
protected void setup() {
    super.setup();
    final TextField lat = new TextField("Lat");
    lat.setValue("" + 60.4525);
    content.addComponentAsFirst(lat);
    final TextField lon = new TextField("Lon");
    lon.setValue("" + 22.301);
    content.addComponentAsFirst(lon);
    final TextField html = new TextField("html");
    content.addComponentAsFirst(html);
    final CheckBox closeButton = new CheckBox("Close button");
    content.addComponentAsFirst(closeButton);
    final CheckBox closeonclick = new CheckBox("Close on click");
    content.addComponentAsFirst(closeonclick);
    content.addComponentAsFirst(new Button("Open popup", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Double lonValue = Double.valueOf(lon.getValue());
            Double latValue = Double.valueOf(lat.getValue());
            LPopup lPopup = new LPopup(latValue, lonValue).setContent(html.getValue());
            lPopup.setCloseButton(closeButton.getValue());
            lPopup.setCloseOnClick(closeonclick.getValue());
            leafletMap.addComponent(lPopup);
            leafletMap.zoomToContent();
            popups.add(lPopup);
            lPopup.addDetachListener(PopupTest.this);
        }
    }));
    content.addComponentAsFirst(new Button("Remove first", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popups.remove(0).close();
        }
    }));
}
Also used : Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) TextField(com.vaadin.ui.TextField) LPopup(org.vaadin.addon.leaflet.LPopup) ClickListener(com.vaadin.ui.Button.ClickListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener)

Example 2 with LPopup

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

the class PopupTest method detach.

@Override
public void detach(DetachEvent event) {
    LPopup popup = (LPopup) event.getConnector();
    Notification.show("Detached " + popup.getContent());
}
Also used : LPopup(org.vaadin.addon.leaflet.LPopup)

Example 3 with LPopup

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

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

the class RemovePopup method getTestComponent.

@Override
public Component getTestComponent() {
    leafletMap = new LMap();
    leafletMap.setWidth("300px");
    leafletMap.setHeight("300px");
    leafletMap.setCenter(0, 0);
    leafletMap.setZoomLevel(2);
    final LPopup popup = new LPopup(5.0, 5.0);
    popup.setContent("Hello!");
    leafletMap.addComponent(popup);
    Button remove = new Button("Remove popup");
    remove.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            leafletMap.removeComponent(popup);
            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) LPopup(org.vaadin.addon.leaflet.LPopup)

Aggregations

LPopup (org.vaadin.addon.leaflet.LPopup)4 Button (com.vaadin.ui.Button)2 LMap (org.vaadin.addon.leaflet.LMap)2 LeafletClickEvent (org.vaadin.addon.leaflet.LeafletClickEvent)2 LeafletClickListener (org.vaadin.addon.leaflet.LeafletClickListener)2 ClickListener (com.vaadin.ui.Button.ClickListener)1 CheckBox (com.vaadin.ui.CheckBox)1 TextField (com.vaadin.ui.TextField)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 LMarker (org.vaadin.addon.leaflet.LMarker)1 LPolyline (org.vaadin.addon.leaflet.LPolyline)1 Point (org.vaadin.addon.leaflet.shared.Point)1 PopupState (org.vaadin.addon.leaflet.shared.PopupState)1