Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle to disable dragging #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/partials/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h5 class="section-heading">Map Visual Options</h5>
</div>
<gf-form-switch class="gf-form" label="Show Legend" label-class="width-10" checked="ctrl.panel.showLegend" on-change="ctrl.toggleLegend()"></gf-form-switch>
<gf-form-switch class="gf-form" label="Mouse Wheel Zoom" label-class="width-10" checked="ctrl.panel.mouseWheelZoom" on-change="ctrl.toggleMouseWheelZoom()"></gf-form-switch>
<gf-form-switch class="gf-form" label="Dragging" label-class="width-10" checked="ctrl.panel.dragging" on-change="ctrl.toggleDragging()"></gf-form-switch>
</div>
<div class="section gf-form-group">
<h5 class="section-heading">Map Data Options</h5>
Expand Down
9 changes: 9 additions & 0 deletions src/worldmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class WorldMap {
zoom: parseInt(this.ctrl.panel.initialZoom, 10) || 1,
});
this.setMouseWheelZoom();
this.setDragging();

const selectedTileServer = tileServers[this.ctrl.tileServer];
(<any>window).L.tileLayer(selectedTileServer.url, {
Expand Down Expand Up @@ -241,6 +242,14 @@ export default class WorldMap {
}
}

setDragging() {
if (!this.ctrl.panel.dragging) {
this.map.dragging.disable();
} else {
this.map.dragging.enable();
}
}

addCircles(circles) {
return (<any>window).L.layerGroup(circles).addTo(this.map);
}
Expand Down
6 changes: 6 additions & 0 deletions src/worldmap_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const panelDefaults = {
unitPlural: "",
showLegend: true,
mouseWheelZoom: false,
dragging: false,
esMetric: "Count",
decimals: 0,
hideEmpty: false,
Expand Down Expand Up @@ -265,6 +266,11 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
this.render();
}

toggleDragging() {
this.map.setDragging();
this.render();
}

toggleStickyLabels() {
this.map.clearCircles();
this.render();
Expand Down