use new location permission api of the android app
This commit is contained in:
parent
64859ab2b4
commit
4506c4956a
1 changed files with 19 additions and 2 deletions
|
@ -768,6 +768,9 @@ c3nav = {
|
||||||
c3nav.open_modal($('#app-ad').html());
|
c3nav.open_modal($('#app-ad').html());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof window.mobileclient.checkLocationPermission === 'function') {
|
||||||
|
window.mobileclient.checkLocationPermission(true);
|
||||||
|
}
|
||||||
if (c3nav._current_user_location) {
|
if (c3nav._current_user_location) {
|
||||||
c3nav._locationinput_set($(this).parent(), c3nav._current_user_location);
|
c3nav._locationinput_set($(this).parent(), c3nav._current_user_location);
|
||||||
c3nav.update_state();
|
c3nav.update_state();
|
||||||
|
@ -1280,9 +1283,18 @@ c3nav = {
|
||||||
if (window.mobileclient) mobileclient.setUserData(JSON.stringify(data));
|
if (window.mobileclient) mobileclient.setUserData(JSON.stringify(data));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_hasLocationPermission: undefined,
|
||||||
|
hasLocationPermission: function() {
|
||||||
|
if (c3nav._hasLocationPermission === undefined) {
|
||||||
|
c3nav._hasLocationPermission = window.mobileclient && (typeof window.mobileclient.hasLocationPermission !== 'function' || window.mobileclient.hasLocationPermission())
|
||||||
|
}
|
||||||
|
return c3nav._hasLocationPermission;
|
||||||
|
},
|
||||||
|
|
||||||
_last_wifi_scant: 0,
|
_last_wifi_scant: 0,
|
||||||
|
|
||||||
_wifi_scan_results: function(data) {
|
_wifi_scan_results: function(data) {
|
||||||
|
c3nav._hasLocationPermission = true;
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
if (now-4000 < c3nav._last_wifi_scan) return;
|
if (now-4000 < c3nav._last_wifi_scan) return;
|
||||||
|
|
||||||
|
@ -1338,8 +1350,10 @@ c3nav = {
|
||||||
stroke: 0,
|
stroke: 0,
|
||||||
fillOpacity: 1
|
fillOpacity: 1
|
||||||
}).addTo(layer);
|
}).addTo(layer);
|
||||||
} else {
|
} else if (c3nav.hasLocationPermission()) {
|
||||||
$('.locationinput .locate, .leaflet-control-user-location a').text('location_searching');
|
$('.locationinput .locate, .leaflet-control-user-location a').text('location_searching');
|
||||||
|
} else {
|
||||||
|
$('.locationinput .locate, .leaflet-control-user-location a').text('location_disabled');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_goto_user_location_click: function (e) {
|
_goto_user_location_click: function (e) {
|
||||||
|
@ -1348,6 +1362,9 @@ c3nav = {
|
||||||
c3nav.open_modal($('#app-ad').html());
|
c3nav.open_modal($('#app-ad').html());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof window.mobileclient.checkLocationPermission === 'function') {
|
||||||
|
window.mobileclient.checkLocationPermission(true);
|
||||||
|
}
|
||||||
if (c3nav._current_user_location) {
|
if (c3nav._current_user_location) {
|
||||||
c3nav._levelControl.setLevel(c3nav._current_user_location.level);
|
c3nav._levelControl.setLevel(c3nav._current_user_location.level);
|
||||||
c3nav.map.flyTo(L.GeoJSON.coordsToLatLng(c3nav._current_user_location.geometry.coordinates), 4, { duration: 1 });
|
c3nav.map.flyTo(L.GeoJSON.coordsToLatLng(c3nav._current_user_location.geometry.coordinates), 4, { duration: 1 });
|
||||||
|
@ -1450,7 +1467,7 @@ UserLocationControl = L.Control.extend({
|
||||||
onAdd: function () {
|
onAdd: function () {
|
||||||
this._container = L.DomUtil.create('div', 'leaflet-control-user-location leaflet-bar ' + this.options.addClasses);
|
this._container = L.DomUtil.create('div', 'leaflet-control-user-location leaflet-bar ' + this.options.addClasses);
|
||||||
this._button = L.DomUtil.create('a', 'material-icons', this._container);
|
this._button = L.DomUtil.create('a', 'material-icons', this._container);
|
||||||
this._button.innerHTML = window.mobileclient ? 'location_searching' : 'location_disabled';
|
this._button.innerHTML = c3nav.hasLocationPermission() ? 'location_searching' : 'location_disabled';
|
||||||
this._button.href = '#';
|
this._button.href = '#';
|
||||||
this.currentLevel = null;
|
this.currentLevel = null;
|
||||||
return this._container;
|
return this._container;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue