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