adt-js-components 1.10.3 → 1.10.5
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 +59 -23
package/package.json
CHANGED
package/src/Map/index.js
CHANGED
|
@@ -142,7 +142,6 @@ async function run(options) {
|
|
|
142
142
|
enableRectangleSelection(map, onSelectionChange, showSelectionOrder);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/** @type {RouteSetting} */
|
|
146
145
|
const markerOptions = {};
|
|
147
146
|
const customMarkerOptions = {};
|
|
148
147
|
const normalImg = customMarkers.normal || markerImg;
|
|
@@ -229,28 +228,39 @@ async function run(options) {
|
|
|
229
228
|
function enableRectangleSelection(map, onSelectionChange, showSelectionOrder) {
|
|
230
229
|
let isDrawing = false;
|
|
231
230
|
let startPoint = null;
|
|
231
|
+
let startPixel = null;
|
|
232
232
|
let rectangle = null;
|
|
233
|
+
const DRAG_THRESHOLD = 8;
|
|
233
234
|
|
|
234
235
|
map.on('mousedown', (e) => {
|
|
235
|
-
if (e.originalEvent.ctrlKey && e.originalEvent.shiftKey) {
|
|
236
|
-
isDrawing = true;
|
|
236
|
+
if ((e.originalEvent.ctrlKey || e.originalEvent.metaKey) && !e.originalEvent.shiftKey) {
|
|
237
237
|
startPoint = e.latlng;
|
|
238
|
-
|
|
238
|
+
startPixel = { x: e.originalEvent.clientX, y: e.originalEvent.clientY };
|
|
239
239
|
map.dragging.disable();
|
|
240
|
-
e.originalEvent.preventDefault();
|
|
241
240
|
}
|
|
242
241
|
});
|
|
243
242
|
|
|
244
243
|
map.on('mousemove', (e) => {
|
|
244
|
+
if (startPoint && !isDrawing) {
|
|
245
|
+
const dx = e.originalEvent.clientX - startPixel.x;
|
|
246
|
+
const dy = e.originalEvent.clientY - startPixel.y;
|
|
247
|
+
if (Math.sqrt(dx * dx + dy * dy) > DRAG_THRESHOLD) {
|
|
248
|
+
isDrawing = true;
|
|
249
|
+
rectangle = L.rectangle([startPoint, startPoint], { color: '#3388ff', weight: 2, fillOpacity: 0.1 }).addTo(map);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
245
252
|
if (isDrawing && rectangle) {
|
|
246
253
|
rectangle.setBounds([startPoint, e.latlng]);
|
|
247
254
|
}
|
|
248
255
|
});
|
|
249
256
|
|
|
250
257
|
map.on('mouseup', (e) => {
|
|
258
|
+
if (startPoint) {
|
|
259
|
+
map.dragging.enable();
|
|
260
|
+
}
|
|
261
|
+
|
|
251
262
|
if (isDrawing) {
|
|
252
263
|
isDrawing = false;
|
|
253
|
-
map.dragging.enable();
|
|
254
264
|
|
|
255
265
|
if (rectangle) {
|
|
256
266
|
const bounds = rectangle.getBounds();
|
|
@@ -287,6 +297,9 @@ function enableRectangleSelection(map, onSelectionChange, showSelectionOrder) {
|
|
|
287
297
|
}
|
|
288
298
|
}
|
|
289
299
|
}
|
|
300
|
+
|
|
301
|
+
startPoint = null;
|
|
302
|
+
startPixel = null;
|
|
290
303
|
});
|
|
291
304
|
}
|
|
292
305
|
|
|
@@ -395,37 +408,59 @@ function createMarker(marker, options, selectedOptions, cluster = null, selectab
|
|
|
395
408
|
|
|
396
409
|
if (selectable && map) {
|
|
397
410
|
mapMarker.on('click', function (e) {
|
|
398
|
-
if (e.originalEvent.
|
|
399
|
-
window[markerInfoCallback](marker);
|
|
411
|
+
if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) {
|
|
400
412
|
L.DomEvent.stopPropagation(e);
|
|
401
413
|
L.DomEvent.preventDefault(e);
|
|
414
|
+
|
|
415
|
+
const selected = selectedMarkers.get(map);
|
|
416
|
+
if (selected.has(marker.id)) {
|
|
417
|
+
deselectMarker(mapMarker, map, showSelectionOrder);
|
|
418
|
+
} else {
|
|
419
|
+
selectMarker(mapMarker, map, showSelectionOrder);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (onSelectionChange && window[onSelectionChange]) {
|
|
423
|
+
const order = selectionOrder.get(map);
|
|
424
|
+
const orderedIds = Array.from(order.entries()).sort((a, b) => a[1] - b[1]).map(e => e[0]);
|
|
425
|
+
window[onSelectionChange](orderedIds);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const settings = routeSettingsMap.get(map);
|
|
429
|
+
if (settings && settings.enabled) {
|
|
430
|
+
calculateRoute(map);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (originalCallback && window[originalCallback]) {
|
|
434
|
+
window[originalCallback](e);
|
|
435
|
+
}
|
|
402
436
|
return;
|
|
403
437
|
}
|
|
404
438
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
439
|
+
if (markerInfoCallback && window[markerInfoCallback]) {
|
|
440
|
+
L.DomEvent.stopPropagation(e);
|
|
441
|
+
L.DomEvent.preventDefault(e);
|
|
442
|
+
window[markerInfoCallback](marker);
|
|
443
|
+
return;
|
|
410
444
|
}
|
|
411
445
|
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
const orderedIds = Array.from(order.entries()).sort((a, b) => a[1] - b[1]).map(e => e[0]);
|
|
415
|
-
window[onSelectionChange](orderedIds);
|
|
446
|
+
if (originalCallback && window[originalCallback]) {
|
|
447
|
+
window[originalCallback](e);
|
|
416
448
|
}
|
|
417
449
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
450
|
+
L.DomEvent.stopPropagation(e);
|
|
451
|
+
});
|
|
452
|
+
} else if (markerInfoCallback || originalCallback) {
|
|
453
|
+
mapMarker.on('click', function (e) {
|
|
454
|
+
if (markerInfoCallback && window[markerInfoCallback]) {
|
|
455
|
+
L.DomEvent.stopPropagation(e);
|
|
456
|
+
L.DomEvent.preventDefault(e);
|
|
457
|
+
window[markerInfoCallback](marker);
|
|
458
|
+
return;
|
|
421
459
|
}
|
|
422
460
|
if (originalCallback && window[originalCallback]) {
|
|
423
461
|
window[originalCallback](e);
|
|
424
462
|
}
|
|
425
|
-
L.DomEvent.stopPropagation(e);
|
|
426
463
|
});
|
|
427
|
-
} else if (originalCallback) {
|
|
428
|
-
mapMarker.on('click', window[originalCallback]);
|
|
429
464
|
}
|
|
430
465
|
|
|
431
466
|
if (marker.popup) {
|
|
@@ -935,6 +970,7 @@ function addMarkerAndSelect(mapElement, markerData, recalculate = true) {
|
|
|
935
970
|
});
|
|
936
971
|
};
|
|
937
972
|
}
|
|
973
|
+
|
|
938
974
|
export default {
|
|
939
975
|
run,
|
|
940
976
|
getSelectedMarkers,
|