use of org.vaadin.addon.leaflet.LMarker in project v-leaflet by mstahv.
the class ZoomToExtendOnInitilaRender method getTestComponent.
@Override
public Component getTestComponent() {
final double[] latitude = { 44.03664d, 43.961669d, 43.859999d };
final double[] longitude = { 11.161893d, 11.129769d, 11.061234d };
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSizeFull();
// Getting my map.
LMap map = new LMap();
map.setControls(new ArrayList<Control>(Arrays.asList(Control.values())));
map.setSizeFull();
// Setting backgroud layer.
map.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
// I am here.
LMarker myPositon = new LMarker(43.894367, 11.078185);
myPositon.setVisible(true);
map.addComponent(myPositon);
// Get random other point.
int idxOther = Math.min((int) (Math.random() * 3.d), 2);
// Put other point on map.
LMarker leafletMarker = new LMarker(latitude[idxOther], longitude[idxOther]);
map.addComponent(leafletMarker);
// Build map bounds.
Point[] mapPoints = { new Point(43.894367, 11.078185), new Point(latitude[idxOther], longitude[idxOther]) };
Bounds mapBounds = new Bounds(mapPoints);
// I'm expecting to see my map with two points.
map.setCenter(mapBounds);
map.zoomToExtent(mapBounds);
layout.addComponent(map);
return layout;
}
use of org.vaadin.addon.leaflet.LMarker 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.LMarker in project v-leaflet by mstahv.
the class PointField method prepareEditing.
@Override
protected void prepareEditing(boolean userOriginatedValueChangeEvent) {
if (marker == null) {
marker = new LMarker(JTSUtil.toLeafletPoint(getCrsTranslator().toPresentation(getValue())));
map.addLayer(marker);
} else {
marker.setPoint(JTSUtil.toLeafletPoint(getCrsTranslator().toPresentation(getValue())));
}
drawRegistration = marker.addDragEndListener(editDragEndListener);
clickRegistration = map.addClickListener(editClickListener);
map.zoomToContent();
}
use of org.vaadin.addon.leaflet.LMarker in project v-leaflet by mstahv.
the class CenterAndZoomTest method doWork.
private void doWork(String... ops) {
trayNotify("got click");
if (marker != null) {
map.removeComponent(marker);
marker = null;
}
double lat = 36;
double lng = -108;
int zoom = 12;
marker = new LMarker(lat, lng);
StringBuilder sb = new StringBuilder();
map.addComponent(marker);
sb.append(" marker");
for (String op : ops) {
if ("c".equals(op)) {
map.setCenter(lat, lng);
sb.append(" center");
} else if ("z".equals(op)) {
map.setZoomLevel(zoom);
sb.append(" zoom");
} else if ("v".equals(op)) {
map.setView(lat, lng, (double) zoom);
// Notification.show("Not yet implemented");
sb.append(" setView");
}
}
trayNotify("Operation sequence:" + sb.toString());
}
use of org.vaadin.addon.leaflet.LMarker 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;
}
Aggregations