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;
}
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;
}
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);
}
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;
}
Aggregations