Add L as the keyboard shortcut for geolocation (close #7395)

This commit is contained in:
Quincy Morgan
2020-02-27 10:23:09 -08:00
parent 28df41bc48
commit f42ad53379
4 changed files with 16 additions and 9 deletions
+7 -8
View File
@@ -4,7 +4,7 @@ import { geoExtent } from '../geo';
import { modeBrowse } from '../modes/browse';
import { svgIcon } from '../svg/icon';
import { uiLoading } from './loading';
import { uiTooltipHtml } from './tooltipHtml';
export function uiGeolocate(context) {
var geoOptions = { enableHighAccuracy: false, timeout: 6000 /* 6sec */ };
@@ -14,7 +14,6 @@ export function uiGeolocate(context) {
var _extent;
var _timeoutID;
function click() {
if (context.inIntro()) return;
context.enter(modeBrowse(context));
@@ -39,7 +38,6 @@ export function uiGeolocate(context) {
map.centerZoomEase(_extent.center(), Math.min(20, map.extentZoom(_extent)));
}
function success(geolocation) {
_position = geolocation;
var coords = _position.coords;
@@ -48,28 +46,29 @@ export function uiGeolocate(context) {
finish();
}
function error() {
finish();
}
function finish() {
locating.close(); // unblock ui
if (_timeoutID) { clearTimeout(_timeoutID); }
_timeoutID = undefined;
}
return function(selection) {
if (!navigator.geolocation) return;
selection
.append('button')
.attr('title', t('geolocate.title'))
.on('click', click)
.call(svgIcon('#iD-icon-geolocate', 'light'))
.call(tooltip()
.placement((textDirection === 'rtl') ? 'right' : 'left'));
.placement((textDirection === 'rtl') ? 'right' : 'left')
.html(true)
.title(uiTooltipHtml(t('geolocate.title'), t('geolocate.key')))
);
context.keybinding().on(t('geolocate.key'), click);
};
}