@@ -109,30 +109,34 @@ const initializeMap = (datasets) => {
109109 props .primaryColor ,
110110 });
111111
112+ if (! Array .isArray (set .features )) {
113+ set .features = [set .features ];
114+ }
115+
112116 set .features .forEach ((location ) => {
113117 const icon = makeMarkerIcon (L , {
114- marker: location .properties ? .marker ,
115- defaultColor: props .primaryColor ,
118+ marker: location .properties ? .marker ,
119+ defaultColor: props .primaryColor ,
116120 });
117121
118- var geojsonLayer = new L.GeoJSON ( location, {
119- pointToLayer : function ( feature , latlng ) {
120- const marker = new L.Marker (latlng, {
121- icon,
122- });
123- marker . on ( ' click ' , () => {
124- tooltipCard . value = makeTooltipCard (location, set );
125- });
126- marker . on ( ' keydown ' , ({ originalEvent }) => {
127- if ( originalEvent . keyCode === 13 ) {
128- tooltipCard . value = makeTooltipCard (location, set);
129- }
130- } );
131-
132- cluster . addLayer (marker);
133- }
134- }). addTo (map);
135- });
122+ // If the location is a MultiPoint, then add the markers directly to the map. If not, add a cluster.
123+ if ( location . geometry . type === ' MultiPoint ' ) {
124+ location . geometry . coordinates . forEach ( coord => {
125+ const pointLatLng = L . latLng (coord[ 1 ], coord[ 0 ]); // Convert coordinates to LatLng.
126+ const marker = new L.Marker (pointLatLng, { icon });
127+ attachEvents (marker);
128+ map . addLayer (marker );
129+ });
130+ } else {
131+ new L.GeoJSON (location, {
132+ pointToLayer : function ( feature , latlng ) {
133+ const marker = new L.Marker (latlng, { icon });
134+ attachEvents (marker );
135+ cluster . addLayer (marker);
136+ }
137+ }). addTo (map);
138+ }
139+ });
136140
137141 return {
138142 id: set .id ,
@@ -141,6 +145,18 @@ const initializeMap = (datasets) => {
141145 };
142146 });
143147
148+ // Function to attach events
149+ function attachEvents (marker ) {
150+ marker .on (' click' , () => {
151+ tooltipCard .value = makeTooltipCard (location, set);
152+ });
153+ marker .on (' keydown' , ({ originalEvent }) => {
154+ if (originalEvent .keyCode === 13 ) {
155+ tooltipCard .value = makeTooltipCard (location, set);
156+ }
157+ });
158+ }
159+
144160 L .Control .DataLayerFilters = L .Control .extend ({
145161 options: {
146162 position: ' topleft' ,
@@ -200,6 +216,7 @@ const initializeMap = (datasets) => {
200216 if (groupedMarkerClusters? .length > 1 ) {
201217 map .addControl (datalayerFilters);
202218 }
219+
203220 groupedMarkerClusters .forEach (({ cluster }) => {
204221 map .addLayer (cluster);
205222 });
0 commit comments