tell user if browser refuses to get location or to register a protocol

This commit is contained in:
Julien Veyssier 2019-04-18 23:51:25 +02:00
Родитель 7c273e1d44
Коммит 7fe18dd4ae
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -688,7 +688,7 @@ DevicesController.prototype = {
this.updateDevicePoints(id);
}
// then get potentially missing devices
this.getDevices(true);
this.getDevices();
},
launchTrackLoop: function() {
@ -706,7 +706,7 @@ DevicesController.prototype = {
sendPositionLoop: function() {
var that = this;
// start a loop which get and send my position
if (navigator.geolocation) {
if (navigator.geolocation && window.isSecureContext) {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
@ -719,6 +719,9 @@ DevicesController.prototype = {
}, 5 * 60 * 1000);
});
}
else {
OC.Notification.showTemporary(t('maps', 'Impossible to get current location'));
}
},
sendMyPosition: function(lat, lng, acc) {

Просмотреть файл

@ -61,12 +61,17 @@ NonLocalizedPhotosController.prototype = {
that.menuSaveAllVisible();
});
if (navigator.geolocation) {
if (navigator.geolocation && window.isSecureContext) {
navigator.geolocation.getCurrentPosition(function (position) {
that.lat = position.coords.latitude;
that.lng = position.coords.longitude;
});
}
else {
this.lat = 0;
this.lng = 0;
OC.Notification.showTemporary(t('maps', 'Impossible to get current location'));
}
},
updateMyFirstLastDates: function() {

Просмотреть файл

@ -1,6 +1,8 @@
(function($, OC) {
$(function() {
window.navigator.registerProtocolHandler('geo', OC.generateUrl('/apps/maps/openGeoLink/') + '%s', 'Nextcloud Maps');
if (window.isSecureContext) {
window.navigator.registerProtocolHandler('geo', OC.generateUrl('/apps/maps/openGeoLink/') + '%s', 'Nextcloud Maps');
}
mapController.initMap();
mapController.map.favoritesController = favoritesController;
favoritesController.initFavorites(mapController.map);