From f0522545340ea3636ec0ef45cc6579f6cab1439e Mon Sep 17 00:00:00 2001 From: Luc Claustres Date: Tue, 14 Jan 2025 14:24:19 +0100 Subject: [PATCH] fix: Box selection does not work when the map is not full height (closes #1043) --- map/client/composables/selection.js | 2 +- map/client/leaflet/BoxSelection.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/map/client/composables/selection.js b/map/client/composables/selection.js index d31297f4e..a50807f72 100644 --- a/map/client/composables/selection.js +++ b/map/client/composables/selection.js @@ -249,7 +249,7 @@ export function useSelection (name, options = {}) { else handleSelection(items, clearSelection) } function onBoxSelection (map, event) { - lastBoxSelectionPosition = L.point(_.get(event, 'x'), _.get(event, 'y')) + lastBoxSelectionPosition = _.get(event, 'containerPoint') const { bounds } = event let items = getIntersectedItems(bboxPolygon([ bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth() diff --git a/map/client/leaflet/BoxSelection.js b/map/client/leaflet/BoxSelection.js index cca832c66..f58132e31 100644 --- a/map/client/leaflet/BoxSelection.js +++ b/map/client/leaflet/BoxSelection.js @@ -80,7 +80,7 @@ export const BoxSelection = L.Handler.extend({ this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._container) L.DomUtil.addClass(this._container, 'leaflet-crosshair') - this._map.fire('boxselectionstart') + this._map.fire('boxselectionstart', Object.assign(e, { containerPoint: this._startPoint })) } this._point = this._map.mouseEventToContainerPoint(e) @@ -127,7 +127,7 @@ export const BoxSelection = L.Handler.extend({ this._map.containerPointToLatLng(this._point)) this._map - .fire('boxselectionend', Object.assign(e, { bounds })) + .fire('boxselectionend', Object.assign(e, { bounds, containerPoint: this._map.mouseEventToContainerPoint(e) })) }, _onKeyDown: function (e) {