mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
@@ -233,6 +233,7 @@ en:
|
||||
no_results_worldwide: No results found
|
||||
geolocate:
|
||||
title: Show My Location
|
||||
locating: "Locating, please wait..."
|
||||
inspector:
|
||||
no_documentation_combination: There is no documentation available for this tag combination
|
||||
no_documentation_key: There is no documentation available for this key
|
||||
|
||||
Vendored
+2
-1
@@ -285,7 +285,8 @@
|
||||
"no_results_worldwide": "No results found"
|
||||
},
|
||||
"geolocate": {
|
||||
"title": "Show My Location"
|
||||
"title": "Show My Location",
|
||||
"locating": "Locating, please wait..."
|
||||
},
|
||||
"inspector": {
|
||||
"no_documentation_combination": "There is no documentation available for this tag combination",
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ iD.ui = function(context) {
|
||||
|
||||
controls.append('div')
|
||||
.attr('class', 'map-control geolocate-control')
|
||||
.call(iD.ui.Geolocate(map));
|
||||
.call(iD.ui.Geolocate(context));
|
||||
|
||||
controls.append('div')
|
||||
.attr('class', 'map-control background-control')
|
||||
|
||||
+25
-6
@@ -1,17 +1,36 @@
|
||||
iD.ui.Geolocate = function(map) {
|
||||
iD.ui.Geolocate = function(context) {
|
||||
var geoOptions = { enableHighAccuracy: false, timeout: 6000 /* 6sec */ },
|
||||
locating = iD.ui.Loading(context).message(t('geolocate.locating')).blocking(true),
|
||||
timeoutId;
|
||||
|
||||
function click() {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
success, error);
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.container().call(locating);
|
||||
navigator.geolocation.getCurrentPosition(success, error, geoOptions);
|
||||
|
||||
// This timeout ensures that we still call finish() even if
|
||||
// the user declines to share their location in Firefox
|
||||
timeoutId = setTimeout(finish, 10000 /* 10sec */ );
|
||||
}
|
||||
|
||||
function success(position) {
|
||||
var extent = iD.geo.Extent([position.coords.longitude, position.coords.latitude])
|
||||
.padByMeters(position.coords.accuracy);
|
||||
var map = context.map(),
|
||||
extent = iD.geo.Extent([position.coords.longitude, position.coords.latitude])
|
||||
.padByMeters(position.coords.accuracy);
|
||||
|
||||
map.centerZoom(extent.center(), Math.min(20, map.extentZoom(extent)));
|
||||
finish();
|
||||
}
|
||||
|
||||
function error() { }
|
||||
function error() {
|
||||
finish();
|
||||
}
|
||||
|
||||
function finish() {
|
||||
locating.close(); // unblock ui
|
||||
if (timeoutId) { clearTimeout(timeoutId); }
|
||||
timeoutId = undefined;
|
||||
}
|
||||
|
||||
return function(selection) {
|
||||
if (!navigator.geolocation) return;
|
||||
|
||||
Reference in New Issue
Block a user