- if ('ondeviceorientationabsolute' in window) {
- L.DomEvent.on(window, 'deviceorientationabsolute', this._onDeviceOrientation, this);
- } else if ('ondeviceorientation' in window) {
- L.DomEvent.on(window, 'deviceorientation', this._onDeviceOrientation, this);
+ var oriAbs = 'ondeviceorientationabsolute' in window;
+ if (oriAbs || ('ondeviceorientation' in window)) {
+ var _this = this;
+ var deviceorientation = function () {
+ L.DomEvent.on(window, oriAbs ? 'deviceorientationabsolute' : 'deviceorientation', _this._onDeviceOrientation, _this);
+ };
+ if (DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === 'function') {
+ DeviceOrientationEvent.requestPermission().then(function (permissionState) {
+ if (permissionState === 'granted') {
+ deviceorientation();
+ }
+ })
+ } else {
+ deviceorientation();
+ }