Skip to content

Commit 099ebad

Browse files
committed
Add leaflet-markercluster
Currently conflicts with maplibre-gl-leaflet
1 parent 5928768 commit 099ebad

File tree

11 files changed

+908
-0
lines changed

11 files changed

+908
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Introduced support for Leaflet plugins #307
88
* Plugins can be installed from ``software.xdev.vaadin.maps-leaflet.plugins:<artifactId>``
99
* The following [plugins](./plugins/) are available:
10+
* leaflet-markercluster
1011
* maplibre-gl-leaflet
1112
* You can also use the [``bom``](./bom/) for easier dependency management
1213

bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
<artifactId>flow</artifactId>
5454
<version>5.0.0-SNAPSHOT</version>
5555
</dependency>
56+
<dependency>
57+
<groupId>software.xdev.vaadin.maps-leaflet.plugins</groupId>
58+
<artifactId>leaflet-markercluster</artifactId>
59+
<version>5.0.0-SNAPSHOT</version>
60+
</dependency>
5661
<dependency>
5762
<groupId>software.xdev.vaadin.maps-leaflet.plugins</groupId>
5863
<artifactId>maplibre-gl-leaflet</artifactId>

flow-demo/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
<artifactId>flow</artifactId>
9999
<version>${project.version}</version>
100100
</dependency>
101+
<dependency>
102+
<groupId>software.xdev.vaadin.maps-leaflet.plugins</groupId>
103+
<artifactId>leaflet-markercluster</artifactId>
104+
<version>${project.version}</version>
105+
</dependency>
101106
<dependency>
102107
<groupId>software.xdev.vaadin.maps-leaflet.plugins</groupId>
103108
<artifactId>maplibre-gl-leaflet</artifactId>

flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/DemoView.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.vaadin.flow.data.renderer.ComponentRenderer;
1313
import com.vaadin.flow.router.PageTitle;
1414
import com.vaadin.flow.router.Route;
15+
import com.vaadin.flow.theme.lumo.LumoUtility;
1516

1617
import software.xdev.vaadin.maps.leaflet.flow.demo.ComplexDemo;
1718
import software.xdev.vaadin.maps.leaflet.flow.demo.EventDemo;
@@ -22,6 +23,7 @@
2223
import software.xdev.vaadin.maps.leaflet.flow.demo.MultiLayerWithPyramidDemo;
2324
import software.xdev.vaadin.maps.leaflet.flow.demo.NotOfThisEarthDemo;
2425
import software.xdev.vaadin.maps.leaflet.flow.demo.WatermarkControlDemo;
26+
import software.xdev.vaadin.maps.leaflet.flow.demo.plugins.LeafletMarkerClusterDemo;
2527
import software.xdev.vaadin.maps.leaflet.flow.demo.plugins.MaplibreGLDemo;
2628

2729

@@ -42,6 +44,8 @@ public DemoView()
4244
spDesc.getStyle().set("white-space", "pre");
4345

4446
final VerticalLayout vl = new VerticalLayout(anchor, spDesc);
47+
vl.addClassName(LumoUtility.Padding.SMALL);
48+
vl.setPadding(false);
4549
vl.setSpacing(false);
4650
return vl;
4751
}))
@@ -105,6 +109,11 @@ protected void onAttach(final AttachEvent attachEvent)
105109
"Freeing up resources Benchmark",
106110
"Benchmark for showcasing how resources a freed up when handling huge amounts of components"
107111
),
112+
new Example(
113+
LeafletMarkerClusterDemo.NAV,
114+
"Plugin: Leaflet.markercluster",
115+
"Showcases markers can be clustered using Leaflet.markercluster"
116+
),
108117
new Example(
109118
MaplibreGLDemo.NAV,
110119
"Plugin: MapLibre GL Leaflet",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package software.xdev.vaadin.maps.leaflet.flow.demo.plugins;
2+
3+
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
4+
import com.vaadin.flow.router.Route;
5+
6+
import software.xdev.vaadin.maps.leaflet.MapContainer;
7+
import software.xdev.vaadin.maps.leaflet.basictypes.LLatLng;
8+
import software.xdev.vaadin.maps.leaflet.layer.other.LMarkerClusterGroup;
9+
import software.xdev.vaadin.maps.leaflet.layer.raster.LTileLayer;
10+
import software.xdev.vaadin.maps.leaflet.layer.ui.LMarker;
11+
import software.xdev.vaadin.maps.leaflet.map.LMap;
12+
import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry;
13+
import software.xdev.vaadin.maps.leaflet.registry.LDefaultComponentManagementRegistry;
14+
15+
16+
@Route(LeafletMarkerClusterDemo.NAV)
17+
@SuppressWarnings("checkstyle:MagicNumber")
18+
public class LeafletMarkerClusterDemo extends VerticalLayout
19+
{
20+
public static final String NAV = "/leaflet-markercluster";
21+
22+
public LeafletMarkerClusterDemo()
23+
{
24+
// Let the view use 100% of the site
25+
this.setSizeFull();
26+
27+
// Create the registry which is needed so that components can be reused and their methods invoked
28+
// Note: You normally don't need to invoke any methods of the registry and just hand it over to the components
29+
final LComponentManagementRegistry reg = new LDefaultComponentManagementRegistry(this);
30+
31+
// Create and add the MapContainer (which contains the map) to the UI
32+
final MapContainer mapContainer = new MapContainer(reg);
33+
mapContainer.setSizeFull();
34+
this.add(mapContainer);
35+
36+
final LMap map = mapContainer.getlMap();
37+
38+
// Add a (default) TileLayer so that we can see something on the map
39+
map.addLayer(LTileLayer.createDefaultForOpenStreetMapTileServer(reg));
40+
41+
// Set what part of the world should be shown
42+
map.setView(new LLatLng(reg, 49.1, 12), 8);
43+
44+
final LMarkerClusterGroup markerClusterGroup = new LMarkerClusterGroup(reg);
45+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.6756, 12.1610))
46+
.bindPopup("XDEV Software"));
47+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.673800, 12.160113))
48+
.bindPopup("Schnitzel"));
49+
50+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.67, 12.16))
51+
.bindPopup("Weiden i.d.OPf."));
52+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.44, 11.86))
53+
.bindPopup("Amberg"));
54+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.33, 12.11))
55+
.bindPopup("Schwandorf"));
56+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.45, 11.08))
57+
.bindPopup("Nürnberg"));
58+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 49.02, 12.1))
59+
.bindPopup("Regensburg"));
60+
markerClusterGroup.addLayer(new LMarker(reg, new LLatLng(reg, 48.14, 11.57))
61+
.bindPopup("München"));
62+
63+
map.addLayer(markerClusterGroup);
64+
}
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Plugin for [Leaflet.markercluster](https://github.com/Leaflet/Leaflet.markercluster)

0 commit comments

Comments
 (0)