Biết liệu có thể truy cập la bàn iPhone trong Safari bằng JavaScript không? Tôi thấy how the GPS can be accessed, nhưng tôi không thể tìm ra la bàn.truy cập la bàn qua iPhone bằng JavaScript
Cảm ơn, như mọi khi!
Biết liệu có thể truy cập la bàn iPhone trong Safari bằng JavaScript không? Tôi thấy how the GPS can be accessed, nhưng tôi không thể tìm ra la bàn.truy cập la bàn qua iPhone bằng JavaScript
Cảm ơn, như mọi khi!
Bạn không thể truy cập thông tin đó thông qua javascript, trừ khi bạn đang sử dụng một cái gì đó giống như iPhoneGap
lúc này là sự thật, trong iOS 5 bạn có thể sử dụng tiêu đề la bàn trong JS. https://developer.apple.com/library/safari/#documentation/SafariDOMAdditions/Reference/DeviceOrientationEventClassRef/DeviceOrientationEvent/DeviceOrientationEvent.html#//apple_ref/javascript/instp/DeviceOrientationEvent/webkitCompassHeading
Cảm ơn, rất vui được biết. –
câu trả lời này không còn đúng, iOS 4.2 cung cấp webkitCompassHeading, hãy xem câu trả lời của awoodland – ianj
Trên iOS, bạn có thể truy xuất giá trị la bàn giá trị như thế này.
window.addEventListener('deviceorientation', function(e) {
console.log(e.webkitCompassHeading);
}, false);
Để biết thêm thông tin, hãy đọc tài liệu Apple DeviceOrientationEvent.
Hy vọng điều này sẽ hữu ích.
tôi khuyên bạn nên sử dụng LeafletJS với plugin này
https://github.com/stefanocudini/leaflet-compass
rất đơn giản để sử dụng với các sự kiện và phương pháp.
Bạn có thể thử một bản demo ở đây:
http://labs.easyblog.it/maps/leaflet-compass/
Chỉ cần nhận thấy dự thảo API này W3C Compass công bố ngày hôm nay: http://dev.w3.org/2009/dap/system-info/compass.html Vì vậy, có lẽ loại chức năng này sẽ đến một chút. –
Trong iOS5, bạn có thể truy cập la bàn với webkitCompassHeading xem [tài liệu này] (https://developer.apple.com/library/safari/#documentation/SafariDOMAdditions/Reference/DeviceOrientationEventClassRef/DeviceOrientationEvent/DeviceOrientationEvent.html#//apple_ref/javascript/instp/DeviceOrientationEvent/webkitCompassHeading) –