Skip to content

Commit

Permalink
Add Option+W shortcut to toggle the OSM data layer (close #6104)
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Apr 19, 2019
1 parent c2b1335 commit b566ef0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,7 @@ en:
fullscreen: "Enter full screen mode"
sidebar: "Toggle sidebar"
wireframe: "Toggle wireframe mode"
osm_data: "Toggle OpenStreetMap data"
minimap: "Toggle minimap"
selecting:
title: "Selecting features"
Expand Down
5 changes: 5 additions & 0 deletions data/shortcuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
"shortcuts": ["area_fill.wireframe.key"],
"text": "shortcuts.browsing.display_options.wireframe"
},
{
"modifiers": [""],
"shortcuts": ["area_fill.wireframe.key"],
"text": "shortcuts.browsing.display_options.osm_data"
},
{
"shortcuts": ["background.minimap.key"],
"text": "shortcuts.browsing.display_options.minimap"
Expand Down
1 change: 1 addition & 0 deletions dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,7 @@
"fullscreen": "Enter full screen mode",
"sidebar": "Toggle sidebar",
"wireframe": "Toggle wireframe mode",
"osm_data": "Toggle OpenStreetMap data",
"minimap": "Toggle minimap"
},
"selecting": {
Expand Down
28 changes: 22 additions & 6 deletions modules/ui/map_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { modeBrowse } from '../modes';
import { uiDisclosure } from './disclosure';
import { uiSettingsCustomData } from './settings/custom_data';
import { uiTooltipHtml } from './tooltipHtml';
import { uiCmd } from './cmd';


export function uiMapData(context) {
var key = t('map_data.key');
var osmDataToggleKey = uiCmd('⌥' + t('area_fill.wireframe.key'));
var features = context.features().keys();
var layers = context.layers();
var fills = ['wireframe', 'partial', 'full'];
Expand Down Expand Up @@ -277,11 +279,20 @@ export function uiMapData(context) {
var labelEnter = liEnter
.append('label')
.each(function(d) {
d3_select(this)
.call(tooltip()
.title(t('map_data.layers.' + d.id + '.tooltip'))
.placement('bottom')
);
if (d.id === 'osm') {
d3_select(this)
.call(tooltip()
.html(true)
.title(uiTooltipHtml(t('map_data.layers.' + d.id + '.tooltip'), osmDataToggleKey))
.placement('bottom')
);
} else {
d3_select(this)
.call(tooltip()
.title(t('map_data.layers.' + d.id + '.tooltip'))
.placement('bottom')
);
}
});

labelEnter
Expand Down Expand Up @@ -820,7 +831,12 @@ export function uiMapData(context) {

context.keybinding()
.on(key, uiMapData.togglePane)
.on(t('area_fill.wireframe.key'), toggleWireframe);
.on(t('area_fill.wireframe.key'), toggleWireframe)
.on(osmDataToggleKey, function() {
d3_event.preventDefault();
d3_event.stopPropagation();
toggleLayer('osm');
});
};

return uiMapData;
Expand Down

0 comments on commit b566ef0

Please sign in to comment.