小编bar*_*rdu的帖子

Leaflet:动态设置min/maxZoom

我正在使用Leaflet v0.7,并且在地图或tileLayer上似乎没有min/maxZoom的setter.

有没有办法动态设置这些值?

leaflet

8
推荐指数
1
解决办法
8224
查看次数

在FF开发工具中查找localStorage

如何查看localStorage中的内容,例如Google Chrome:资源 - >本地存储

(我的意思是在FF开发工具,而不是Firebug)

firefox firefox-developer-tools

7
推荐指数
2
解决办法
2562
查看次数

从DeviceOrientation事件API计算罗盘方向

对于智能手机的增强现实网络应用程序,我正在尝试计算当用户手持设备时的罗盘方向,屏幕在垂直平面中,屏幕顶部朝上.

我从http://dev.w3.org/geo/api/spec-source-orientation(参见工作示例)中采用了建议的公式,并实现了以下功能:

function compassHeading(alpha, beta, gamma) {
    var a1, a2, b1, b2;
    if ( beta !== 0 || gamma !== 0 ) {
        a1 = -Math.cos(alpha) * Math.sin(gamma);
        a2 = Math.sin(alpha) * Math.sin(beta) * Math.cos(gamma);
        b1 = -Math.sin(alpha) * Math.sin(gamma);
        b2 = Math.cos(alpha) * Math.sin(beta) * Math.cos(gamma);
        return Math.atan((a1 - a2) / (b1 + b2)).toDeg();
    }
    else {
        return 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

而.toDeg()是一个Number对象扩展,由http://www.movable-type.co.uk/scripts/latlong.html提供

/** Converts radians to numeric (signed) degrees */
if (typeof Number.prototype.toDeg == 'undefined') { …
Run Code Online (Sandbox Code Playgroud)

math firefox html5 google-chrome

5
推荐指数
1
解决办法
7336
查看次数