adt-js-components 1.10.2 → 1.10.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Map/index.js +38 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adt-js-components",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "JavaScript components for Nette framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Map/index.js CHANGED
@@ -21,6 +21,7 @@ const markerClusters = new WeakMap();
21
21
  const onSelectionChangeMap = new WeakMap();
22
22
  const onBeforeRouteCalculationMap = new WeakMap();
23
23
  const onAfterRouteCalculationMap = new WeakMap();
24
+ const disableClickZoomMap = new WeakMap();
24
25
 
25
26
  const DEPOT_TYPE = {
26
27
  START: 'depot-start',
@@ -53,6 +54,7 @@ async function run(options) {
53
54
  markerInfoCallback = null,
54
55
  onBeforeRouteCalculation = null,
55
56
  onAfterRouteCalculation = null,
57
+ disableClickZoom = false
56
58
  } = JSON.parse(el.dataset.adtMap);
57
59
 
58
60
  const routeSettings = {
@@ -78,6 +80,7 @@ async function run(options) {
78
80
  onSelectionChangeMap.set(map, onSelectionChange);
79
81
  onBeforeRouteCalculationMap.set(map, onBeforeRouteCalculation);
80
82
  onAfterRouteCalculationMap.set(map, onAfterRouteCalculation);
83
+ disableClickZoomMap.set(map, disableClickZoom);
81
84
 
82
85
  if (mapProvider === MAP_PROVIDER.HERE) {
83
86
  L.tileLayer(
@@ -229,7 +232,7 @@ function enableRectangleSelection(map, onSelectionChange, showSelectionOrder) {
229
232
  let rectangle = null;
230
233
 
231
234
  map.on('mousedown', (e) => {
232
- if (e.originalEvent.ctrlKey && e.originalEvent.shiftKey) {
235
+ if (e.originalEvent.ctrlKey && !e.originalEvent.shiftKey) {
233
236
  isDrawing = true;
234
237
  startPoint = e.latlng;
235
238
  rectangle = L.rectangle([startPoint, startPoint], { color: '#3388ff', weight: 2, fillOpacity: 0.1 }).addTo(map);
@@ -392,33 +395,45 @@ function createMarker(marker, options, selectedOptions, cluster = null, selectab
392
395
 
393
396
  if (selectable && map) {
394
397
  mapMarker.on('click', function (e) {
395
- if (e.originalEvent.shiftKey && !e.originalEvent.ctrlKey && markerInfoCallback && window[markerInfoCallback]) {
396
- window[markerInfoCallback](marker);
398
+ if (e.originalEvent.ctrlKey) {
397
399
  L.DomEvent.stopPropagation(e);
398
400
  L.DomEvent.preventDefault(e);
399
- return;
400
- }
401
401
 
402
- const selected = selectedMarkers.get(map);
403
- if (selected.has(marker.id)) {
404
- deselectMarker(mapMarker, map, showSelectionOrder);
405
- } else {
406
- selectMarker(mapMarker, map, showSelectionOrder);
407
- }
402
+ const selected = selectedMarkers.get(map);
403
+ if (selected.has(marker.id)) {
404
+ deselectMarker(mapMarker, map, showSelectionOrder);
405
+ } else {
406
+ selectMarker(mapMarker, map, showSelectionOrder);
407
+ }
408
408
 
409
- if (onSelectionChange && window[onSelectionChange]) {
410
- const order = selectionOrder.get(map);
411
- const orderedIds = Array.from(order.entries()).sort((a, b) => a[1] - b[1]).map(e => e[0]);
412
- window[onSelectionChange](orderedIds);
409
+ if (onSelectionChange && window[onSelectionChange]) {
410
+ const order = selectionOrder.get(map);
411
+ const orderedIds = Array.from(order.entries()).sort((a, b) => a[1] - b[1]).map(e => e[0]);
412
+ window[onSelectionChange](orderedIds);
413
+ }
414
+
415
+ const settings = routeSettingsMap.get(map);
416
+ if (settings && settings.enabled) {
417
+ calculateRoute(map);
418
+ }
419
+
420
+ if (originalCallback && window[originalCallback]) {
421
+ window[originalCallback](e);
422
+ }
423
+ return;
413
424
  }
414
425
 
415
- const settings = routeSettingsMap.get(map);
416
- if (settings && settings.enabled) {
417
- calculateRoute(map);
426
+ if (markerInfoCallback && window[markerInfoCallback]) {
427
+ L.DomEvent.stopPropagation(e);
428
+ L.DomEvent.preventDefault(e);
429
+ window[markerInfoCallback](marker);
430
+ return;
418
431
  }
432
+
419
433
  if (originalCallback && window[originalCallback]) {
420
434
  window[originalCallback](e);
421
435
  }
436
+
422
437
  L.DomEvent.stopPropagation(e);
423
438
  });
424
439
  } else if (originalCallback) {
@@ -625,7 +640,10 @@ async function calculateRoute(map) {
625
640
  opacity: routeSettings.opacity
626
641
  }).addTo(map);
627
642
  routePolylines.set(map, polyline);
628
- map.fitBounds(polyline.getBounds(), { padding: [32, 32] });
643
+
644
+ if (!disableClickZoomMap.get(map)) {
645
+ map.fitBounds(polyline.getBounds(), {padding: [32, 32]});
646
+ }
629
647
  }
630
648
 
631
649
  const totalDuration = allParts.reduce((s, p) => s + (p.duration || 0), 0);
@@ -929,6 +947,7 @@ function addMarkerAndSelect(mapElement, markerData, recalculate = true) {
929
947
  });
930
948
  };
931
949
  }
950
+
932
951
  export default {
933
952
  run,
934
953
  getSelectedMarkers,