Add shortcut to toggle Strava layer
Press 'S' to show the Strava buttons (if the API key has been set) as well as the Strava segments layer (once it has been fetched). Note that fetching and updating data from Strava still needs to be triggered manually by clicking the respective biking or running button.
This commit is contained in:
parent
e4e1c8a19e
commit
ba0bb39fd5
2 changed files with 23 additions and 2 deletions
|
|
@ -16,6 +16,12 @@ BR.stravaSegments = function(map, layersControl) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
L.setOptions(this, {
|
||||||
|
shortcut: {
|
||||||
|
toggleLayer: 83 // char code for 's'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// hide strava buttons when layer is inactive
|
// hide strava buttons when layer is inactive
|
||||||
var toggleStravaControl = function() {
|
var toggleStravaControl = function() {
|
||||||
var stravaBar = stravaControl.runningButton.button.parentElement;
|
var stravaBar = stravaControl.runningButton.button.parentElement;
|
||||||
|
|
@ -24,5 +30,20 @@ BR.stravaSegments = function(map, layersControl) {
|
||||||
toggleStravaControl();
|
toggleStravaControl();
|
||||||
stravaControl.stravaLayer.on('add remove', toggleStravaControl);
|
stravaControl.stravaLayer.on('add remove', toggleStravaControl);
|
||||||
|
|
||||||
|
L.DomEvent.addListener(
|
||||||
|
document,
|
||||||
|
'keydown',
|
||||||
|
function(e) {
|
||||||
|
if (BR.Util.keyboardShortcutsAllowed(e) && e.keyCode === this.options.shortcut.toggleLayer) {
|
||||||
|
if (map.hasLayer(stravaControl.stravaLayer)) {
|
||||||
|
map.removeLayer(stravaControl.stravaLayer);
|
||||||
|
} else {
|
||||||
|
map.addLayer(stravaControl.stravaLayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
return stravaControl;
|
return stravaControl;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@
|
||||||
"route-quality-altitude": "Altitude coding (C key to toggle)",
|
"route-quality-altitude": "Altitude coding (C key to toggle)",
|
||||||
"route-quality-cost": "Cost coding (C key to toggle)",
|
"route-quality-cost": "Cost coding (C key to toggle)",
|
||||||
"route-quality-incline": "Incline coding (C key to toggle)",
|
"route-quality-incline": "Incline coding (C key to toggle)",
|
||||||
"strava-biking": "Show Strava biking segments",
|
"strava-biking": "Show Strava biking segments\n(S key to toggle layer, click to reload for current area)",
|
||||||
"strava-running": "Show Strava running segments",
|
"strava-running": "Show Strava running segments\n(S key to toggle layer, click to reload for current area)",
|
||||||
"zoomInTitle": "Zoom in (+ key)",
|
"zoomInTitle": "Zoom in (+ key)",
|
||||||
"zoomOutTitle": "Zoom out (- key)"
|
"zoomOutTitle": "Zoom out (- key)"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue