如何停止 mapbox-gl.js 跟踪我的移动指南针
How to stop mapbox-gl.js tracking my mobile compass
当我在手机上使用 mapbox-gl.js 地图时 phone 它会在我转动手机时一直旋转 phone 以保持北方。我怎样才能阻止这个?我确实希望继续能够使用触摸手势旋转地图...
这里是 api.
嗯...,抱歉,方位跟踪目前不在 mapbox-gl.js api 中。这是 'my own' 代码。我从某处调整并忘记了......的片段:
const easing = t => t * (2 - t)
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', event => {
let compassdir
if (event.webkitCompassHeading) {
// Apple works only with this, alpha doesn't work
compassdir = event.webkitCompassHeading
}
else {
compassdir = event.alpha
}
myMap.easeTo({
bearing: 360 - compassdir,
easing: easing
})
})
}
else {
alert("Sorry, your browser doesn't support Device Orientation")
}
当我在手机上使用 mapbox-gl.js 地图时 phone 它会在我转动手机时一直旋转 phone 以保持北方。我怎样才能阻止这个?我确实希望继续能够使用触摸手势旋转地图...
这里是 api.
嗯...,抱歉,方位跟踪目前不在 mapbox-gl.js api 中。这是 'my own' 代码。我从某处调整并忘记了......的片段:
const easing = t => t * (2 - t)
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', event => {
let compassdir
if (event.webkitCompassHeading) {
// Apple works only with this, alpha doesn't work
compassdir = event.webkitCompassHeading
}
else {
compassdir = event.alpha
}
myMap.easeTo({
bearing: 360 - compassdir,
easing: easing
})
})
}
else {
alert("Sorry, your browser doesn't support Device Orientation")
}