From 4707bbed8d25bdac2d6a0281f9b2bdac31b97a72 Mon Sep 17 00:00:00 2001 From: Gareth Dunstone Date: Thu, 6 Feb 2020 09:14:28 +1000 Subject: [PATCH] Add a toggle to disable panning/dragging on the map * added dragging toggle * added option to disable double click zoom as well * forgot to call setter on init --- src/partials/editor.html | 5 ++++- src/worldmap.ts | 18 ++++++++++++++++++ src/worldmap_ctrl.ts | 12 ++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/partials/editor.html b/src/partials/editor.html index ac9e524..8cb9424 100644 --- a/src/partials/editor.html +++ b/src/partials/editor.html @@ -361,7 +361,10 @@
Appearance
- + + + +
diff --git a/src/worldmap.ts b/src/worldmap.ts index 656979c..c81fc77 100644 --- a/src/worldmap.ts +++ b/src/worldmap.ts @@ -47,6 +47,8 @@ export default class WorldMap { attributionControl: this.ctrl.settings.showAttribution, }); this.setMouseWheelZoom(); + this.setDragging(); + this.setDoubleClickZoom(); const selectedTileServer = tileServers[this.ctrl.tileServer]; (window as any).L.tileLayer(selectedTileServer.url, { @@ -445,6 +447,22 @@ export default class WorldMap { } } + setDragging() { + if (!this.ctrl.settings.dragging) { + this.map.dragging.disable(); + } else { + this.map.dragging.enable(); + } + } + + setDoubleClickZoom() { + if (!this.ctrl.settings.doubleClickZoom) { + this.map.doubleClickZoom.disable(); + } else { + this.map.doubleClickZoom.enable(); + } + } + addCircles(circles) { // Todo: Optionally add fixed custom attributions to the circle layer. const attribution = undefined; diff --git a/src/worldmap_ctrl.ts b/src/worldmap_ctrl.ts index 695b1a8..ad711fe 100644 --- a/src/worldmap_ctrl.ts +++ b/src/worldmap_ctrl.ts @@ -40,6 +40,8 @@ const panelDefaults = { customAttribution: false, customAttributionText: null, mouseWheelZoom: false, + dragging: true, + doubleClickZoom: true, esGeoPoint: null, // Todo: Investigate: Is "Count" a reasonable default here // or does it confuse the operator? @@ -504,6 +506,16 @@ export default class WorldmapCtrl extends MetricsPanelCtrl { this.render(); } + toggleDragging() { + this.map.setDragging(); + this.render(); + } + + toggleDoubleClickZoom() { + this.map.setDoubleClickZoom(); + this.render(); + } + toggleCustomAttribution() { if (this.settings.customAttribution) { const attributionControl = this.map.map.attributionControl;