diff --git a/dist/charting.js b/dist/charting.js index 329e6d16..bc198968 100644 --- a/dist/charting.js +++ b/dist/charting.js @@ -38715,12 +38715,20 @@ function mapMixin(_chart, chartDivId, _mapboxgl) { }); _map.dragRotate.disable(); _map.touchZoomRotate.disableRotation(); - _map.addControl(new __WEBPACK_IMPORTED_MODULE_5__mapbox_controls_ruler__["a" /* default */]({ + var rulerControl = new __WEBPACK_IMPORTED_MODULE_5__mapbox_controls_ruler__["a" /* default */]({ linePaint: { "line-color": "#999", "line-width": 2 } - }), "bottom-right"); + }); + _map.addControl(rulerControl, "bottom-right"); + _chart.root().on("keydown", function () { + if (__WEBPACK_IMPORTED_MODULE_0_d3___default.a.event.key === "Escape" || __WEBPACK_IMPORTED_MODULE_0_d3___default.a.event.key === 27) { + if (rulerControl !== null && rulerControl !== void 0 && rulerControl.isActive) { + rulerControl.deactivate(); + } + } + }); _map.addControl(new _mapboxgl.NavigationControl(), "bottom-right"); _map.addControl(new _mapboxgl.AttributionControl(), _attribLocation); _map.addControl(new _mapboxgl.ScaleControl({ diff --git a/src/mixins/map-mixin.js b/src/mixins/map-mixin.js index f3c12252..70b70e69 100644 --- a/src/mixins/map-mixin.js +++ b/src/mixins/map-mixin.js @@ -738,15 +738,21 @@ export default function mapMixin( _map.dragRotate.disable() _map.touchZoomRotate.disableRotation() - _map.addControl( - new RulerControl({ - linePaint: { - "line-color": "#999", - "line-width": 2 + const rulerControl = new RulerControl({ + linePaint: { + "line-color": "#999", + "line-width": 2 + } + }) + _map.addControl(rulerControl, "bottom-right") + + _chart.root().on("keydown", () => { + if (d3.event.key === "Escape" || d3.event.key === 27) { + if (rulerControl?.isActive) { + rulerControl.deactivate() } - }), - "bottom-right" - ) + } + }) _map.addControl(new _mapboxgl.NavigationControl(), "bottom-right") _map.addControl(new _mapboxgl.AttributionControl(), _attribLocation) _map.addControl(