adt-js-components 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Map/index.js +31 -23
package/package.json
CHANGED
package/src/Map/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const onSelectionChangeMap = new WeakMap();
|
|
|
23
23
|
const onBeforeRouteCalculationMap = new WeakMap();
|
|
24
24
|
const onAfterRouteCalculationMap = new WeakMap();
|
|
25
25
|
const disableClickZoomMap = new WeakMap();
|
|
26
|
+
const disableClusteringMap = new WeakMap();
|
|
26
27
|
const cachedRouteLoaded = new WeakMap();
|
|
27
28
|
|
|
28
29
|
const DEPOT_TYPE = {
|
|
@@ -56,7 +57,8 @@ async function run(options) {
|
|
|
56
57
|
markerInfoCallback = null,
|
|
57
58
|
onBeforeRouteCalculation = null,
|
|
58
59
|
onAfterRouteCalculation = null,
|
|
59
|
-
disableClickZoom = false
|
|
60
|
+
disableClickZoom = false,
|
|
61
|
+
disableClustering = false
|
|
60
62
|
} = JSON.parse(el.dataset.adtMap);
|
|
61
63
|
|
|
62
64
|
/** @type {RouteSetting} */
|
|
@@ -91,6 +93,7 @@ async function run(options) {
|
|
|
91
93
|
onBeforeRouteCalculationMap.set(map, onBeforeRouteCalculation);
|
|
92
94
|
onAfterRouteCalculationMap.set(map, onAfterRouteCalculation);
|
|
93
95
|
disableClickZoomMap.set(map, disableClickZoom);
|
|
96
|
+
disableClusteringMap.set(map, disableClustering);
|
|
94
97
|
|
|
95
98
|
if (mapProvider === MAP_PROVIDER.HERE) {
|
|
96
99
|
L.tileLayer(
|
|
@@ -334,21 +337,23 @@ function enableRectangleSelection(map, onSelectionChange, showSelectionOrder) {
|
|
|
334
337
|
|
|
335
338
|
function addMarkers(map, markers, options, selectedOptions, position, selectable, onSelectionChange, showSelectionOrder, markerInfoCallback) {
|
|
336
339
|
const positionsOfMarkers = [];
|
|
337
|
-
const cluster =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
340
|
+
const cluster = disableClusteringMap.get(map)
|
|
341
|
+
? L.layerGroup()
|
|
342
|
+
: L.markerClusterGroup({
|
|
343
|
+
disableClusteringAtZoom: 18,
|
|
344
|
+
spiderfyOnMaxZoom: true,
|
|
345
|
+
showCoverageOnHover: false,
|
|
346
|
+
zoomToBoundsOnClick: true,
|
|
347
|
+
iconCreateFunction: function (cluster) {
|
|
348
|
+
const childCount = cluster.getChildCount();
|
|
349
|
+
const c = childCount < 10 ? 'small' : childCount < 100 ? 'medium' : 'large';
|
|
350
|
+
return new L.DivIcon({
|
|
351
|
+
html: '<div><span>' + childCount + '</span></div>',
|
|
352
|
+
className: 'marker-cluster marker-cluster-' + c,
|
|
353
|
+
iconSize: new L.Point(40, 40)
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
352
357
|
|
|
353
358
|
markerClusters.set(map, cluster);
|
|
354
359
|
let loadedCount = 0;
|
|
@@ -411,9 +416,9 @@ async function applyPreselectedMarkersVisualOnly(map, markersData) {
|
|
|
411
416
|
for (const markerData of preselected) {
|
|
412
417
|
const markerInstance = markerMap.get(markerData.id);
|
|
413
418
|
if (markerInstance && markerInstance._selectedIcon) {
|
|
414
|
-
if (settings && settings.color) {
|
|
419
|
+
if ((settings && settings.color) || markerData.iconStyle) {
|
|
415
420
|
const iconUrl = markerInstance._selectedIcon.options.iconUrl;
|
|
416
|
-
const newIcon = await createMarkerIcon(map, iconUrl, null);
|
|
421
|
+
const newIcon = await createMarkerIcon(map, iconUrl, null, null, markerData.iconStyle);
|
|
417
422
|
markerInstance.setIcon(newIcon);
|
|
418
423
|
} else {
|
|
419
424
|
markerInstance.setIcon(markerInstance._selectedIcon);
|
|
@@ -542,7 +547,7 @@ async function selectMarker(marker, map, showSelectionOrder) {
|
|
|
542
547
|
}
|
|
543
548
|
|
|
544
549
|
if (showSelectionOrder) {
|
|
545
|
-
const newIcon = await createMarkerIcon(map, marker.options.icon.options.iconUrl, newOrder);
|
|
550
|
+
const newIcon = await createMarkerIcon(map, marker.options.icon.options.iconUrl, newOrder, null, marker._markerData?.iconStyle);
|
|
546
551
|
marker.setIcon(newIcon);
|
|
547
552
|
}
|
|
548
553
|
}
|
|
@@ -581,16 +586,19 @@ function deselectMarker(marker, map, showSelectionOrder) {
|
|
|
581
586
|
async function updateMarkerOrderDisplay(map, marker, orderNumber, isSelected, color = null) {
|
|
582
587
|
if (!marker._normalIcon || !marker._normalIcon.options) return;
|
|
583
588
|
const iconUrl = isSelected && marker._selectedIcon ? marker._selectedIcon.options.iconUrl : marker._normalIcon.options.iconUrl;
|
|
584
|
-
const newIcon = await createMarkerIcon(map, iconUrl, orderNumber, color);
|
|
589
|
+
const newIcon = await createMarkerIcon(map, iconUrl, orderNumber, color, marker._markerData?.iconStyle);
|
|
585
590
|
marker.setIcon(newIcon);
|
|
586
591
|
}
|
|
587
592
|
|
|
588
|
-
async function createMarkerIcon(map, iconUrl, orderNumber, color = null) {
|
|
589
|
-
let inlineStyle =
|
|
593
|
+
async function createMarkerIcon(map, iconUrl, orderNumber, color = null, iconStyle = null) {
|
|
594
|
+
let inlineStyle = '';
|
|
590
595
|
const settings = routeSettingsMap.get(map);
|
|
591
596
|
if ((settings && settings.color) || color) {
|
|
592
597
|
inlineStyle = `--marker-fill: ${color ?? settings.color};`;
|
|
593
598
|
}
|
|
599
|
+
if (iconStyle) {
|
|
600
|
+
inlineStyle += iconStyle;
|
|
601
|
+
}
|
|
594
602
|
|
|
595
603
|
let svg;
|
|
596
604
|
if (svgCache.has(iconUrl)) {
|
|
@@ -903,7 +911,7 @@ async function toggleMarker(mapElement, markerId, selected, recalculate = true)
|
|
|
903
911
|
}
|
|
904
912
|
|
|
905
913
|
const cluster = markerClusters.get(map);
|
|
906
|
-
if (cluster) {
|
|
914
|
+
if (cluster && typeof cluster.refreshClusters === 'function') {
|
|
907
915
|
cluster.refreshClusters(marker);
|
|
908
916
|
}
|
|
909
917
|
|