adt-js-components 1.5.4 → 1.5.6
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 +41 -29
package/package.json
CHANGED
package/src/Map/index.js
CHANGED
|
@@ -46,7 +46,11 @@ async function run(options) {
|
|
|
46
46
|
new LogoControl().addTo(map);
|
|
47
47
|
|
|
48
48
|
if (position.length) {
|
|
49
|
-
|
|
49
|
+
if (zoom) {
|
|
50
|
+
map.setView(position, zoom);
|
|
51
|
+
} else {
|
|
52
|
+
map.fitBounds([position]);
|
|
53
|
+
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
map.scrollWheelZoom.disable();
|
|
@@ -58,34 +62,42 @@ async function run(options) {
|
|
|
58
62
|
|
|
59
63
|
const markerOptions = {};
|
|
60
64
|
if (markerImg) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
const img = new Image();
|
|
66
|
+
img.src = markerImg;
|
|
67
|
+
img.onload = function () {
|
|
68
|
+
markerOptions.icon = L.icon({
|
|
69
|
+
iconUrl: markerImg,
|
|
70
|
+
iconSize: [img.width, img.height],
|
|
71
|
+
iconAnchor: [img.width / 2, img.height]
|
|
72
|
+
});
|
|
73
|
+
if (markers.length) {
|
|
74
|
+
const markerPositions = [];
|
|
75
|
+
const cluster = L.markerClusterGroup({
|
|
76
|
+
disableClusteringAtZoom: map.getMaxZoom()
|
|
77
|
+
});
|
|
78
|
+
for (const marker of markers) {
|
|
79
|
+
const mapMarker = L.marker(marker.position, {...markerOptions, id: marker.id});
|
|
80
|
+
if (marker.callback) {
|
|
81
|
+
mapMarker.on('click', window[marker.callback]);
|
|
82
|
+
}
|
|
83
|
+
if (marker.popup) {
|
|
84
|
+
mapMarker.bindPopup(marker.popup);
|
|
85
|
+
} else if (marker.popupCallback) {
|
|
86
|
+
mapMarker.bindPopup(() => window[marker.popupCallback](mapMarker));
|
|
87
|
+
}
|
|
88
|
+
if (!marker.excludeFromBoundary) {
|
|
89
|
+
markerPositions.push(marker.position);
|
|
90
|
+
}
|
|
91
|
+
cluster.addLayer(mapMarker);
|
|
92
|
+
}
|
|
93
|
+
if (!position.length) {
|
|
94
|
+
map.fitBounds(markerPositions);
|
|
95
|
+
}
|
|
96
|
+
map.addLayer(cluster);
|
|
97
|
+
} else {
|
|
98
|
+
L.marker(position, markerOptions).addTo(map);
|
|
80
99
|
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
if (!position.length) {
|
|
84
|
-
map.fitBounds(markerPositions);
|
|
85
|
-
}
|
|
86
|
-
map.addLayer(cluster);
|
|
87
|
-
} else {
|
|
88
|
-
L.marker(position, markerOptions).addTo(map);
|
|
100
|
+
};
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
if (callback) {
|
|
@@ -100,7 +112,7 @@ async function run(options) {
|
|
|
100
112
|
if (mutation.type === "childList") {
|
|
101
113
|
mutation.addedNodes.forEach(node => {
|
|
102
114
|
if (node.nodeType === 1 && node.hasAttribute("data-adt-map")) {
|
|
103
|
-
|
|
115
|
+
applyEventHandlers(node);
|
|
104
116
|
}
|
|
105
117
|
});
|
|
106
118
|
}
|