use of org.vaadin.addon.leaflet.LOpenStreetMapLayer in project v-leaflet by mstahv.
the class ZoomToExtendPointOnly 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);
map.addComponent(lMarker);
map.zoomToContent();
layout.addComponent(map);
return layout;
}
use of org.vaadin.addon.leaflet.LOpenStreetMapLayer in project v-leaflet by mstahv.
the class AddOverlayBugTest method getTestComponent.
@Override
public Component getTestComponent() {
VerticalLayout lmapContainer = new VerticalLayout();
lmapContainer.setMargin(true);
// create leaflet map
lmap = new LMap();
lmap.setCenter(40.712216, -74.22655);
lmap.setWidth("500px");
lmap.setHeight("400px");
lmapContainer.addComponent(lmap);
// base laser 1 & 2 (dummy base layers)
LOpenStreetMapLayer osm1 = new LOpenStreetMapLayer();
osm1.setActive(false);
lmap.addBaseLayer(osm1, "Base Layer 1");
LTileLayer osm2 = new LTileLayer("https://a.tile.thunderforest.com/cycle/{z}/{x}/{y}.png");
osm2.setAttributionString("© OpenStreetMap contributors. Tiles courtesy of Andy Allan");
osm2.setActive(true);
lmap.addBaseLayer(osm2, "Base Layer 2");
// BUG: after removing/adding the base layer and also existing wms layers are duplicated
Button wmsLayerRemoveAddButton = new Button("Add");
wmsLayerRemoveAddButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
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");
lmap.addOverlay(imageOverlay, "imagelayer-" + System.currentTimeMillis());
// dummy wms layer
LWmsLayer result = new LWmsLayer();
result.setFormat("image/png");
result.setUrl("not/working/url/to/your/geoserver");
result.setLayers("layerselection");
// add new wms layer
lmap.addOverlay(result, "layer-" + System.currentTimeMillis());
}
});
lmapContainer.addComponent(wmsLayerRemoveAddButton);
return lmapContainer;
}
use of org.vaadin.addon.leaflet.LOpenStreetMapLayer in project v-leaflet by mstahv.
the class ContextClickOnMap method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
final LOpenStreetMapLayer lOpenStreetMapLayer = new LOpenStreetMapLayer();
leafletMap.addLayer(lOpenStreetMapLayer);
leafletMap.setCenter(0, 0);
leafletMap.setZoomLevel(2);
LPolygon polygon = new LPolygon(new Point(0, 0), new Point(30, 30), new Point(0, 30));
leafletMap.addLayer(polygon);
polygon.addContextMenuListener(new LeafletContextMenuListener() {
@Override
public void onContextMenu(LeafletContextMenuEvent event) {
Notification.show("CxtClick at polygon at " + event.toString());
}
});
polygon.addClickListener(new LeafletClickListener() {
@Override
public void onClick(LeafletClickEvent event) {
Notification.show("Std Click at polygon at " + event.toString());
}
});
// prevent bubbling of events to DOM parents(like the map)
polygon.setBubblingMouseEvents(false);
leafletMap.addContextMenuListener(new LeafletContextMenuListener() {
@Override
public void onContextMenu(LeafletContextMenuEvent event) {
Point point = event.getPoint();
LMarker marker = new LMarker(point);
marker.setPopup("Created by ContextClick on lOpenStreetMapLayer");
leafletMap.addComponent(marker);
marker.openPopup();
}
});
leafletMap.addClickListener(new LeafletClickListener() {
@Override
public void onClick(LeafletClickEvent event) {
if (event.getMouseEvent().getButton() == MouseEventDetails.MouseButton.LEFT) {
Notification.show("Std Click on map at " + event.toString() + ". Use context click to add marker.");
}
}
});
return leafletMap;
}
use of org.vaadin.addon.leaflet.LOpenStreetMapLayer in project v-leaflet by mstahv.
the class ContinuousWorld method getTestComponent.
@Override
public Component getTestComponent() {
LMap leafletMap = new LMap();
LOpenStreetMapLayer layer = new LOpenStreetMapLayer();
// default false
layer.setNoWrap(true);
leafletMap.addBaseLayer(layer, "OSM");
leafletMap.setCenter(0, 0);
leafletMap.setZoomLevel(0);
// Should cross pacific ocean
LPolyline lPolyline = new LPolyline(new Point(0, 360), new Point(0, 390));
leafletMap.addComponent(lPolyline);
return leafletMap;
}
use of org.vaadin.addon.leaflet.LOpenStreetMapLayer in project v-leaflet by mstahv.
the class ControlTest method getTestComponent.
@Override
public Component getTestComponent() {
leafletMap = new LMap();
leafletMap.setCenter(60.4525, 22.301);
leafletMap.setZoomLevel(15);
leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
/*
* Using nameless api, doesn't add layers control
*/
// leafletMap.addLayer(baselayer);
/*
* Layers control can also be removed manually
*/
// leafletMap.getLayersControl().remove();
scale.setPosition(ControlPosition.topright);
scale.setImperial(false);
scale.setMetric(true);
leafletMap.addControl(scale);
/*
* DEFAULT CONTROLS These are on there by default, but can be customized
* and disabled if needed.
*/
LAttribution attribution = new LAttribution();
attribution.setPrefix("Leaflet with Java in JVM");
attribution.setPosition(ControlPosition.bottomleft);
// attribution.setEnabled(false);
leafletMap.addControl(attribution);
LZoom zoom = new LZoom();
zoom.setPosition(ControlPosition.bottomright);
// zoom.setEnabled(false);
leafletMap.addControl(zoom);
return leafletMap;
}
Aggregations