cd-mapgis 1.0.67 → 1.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/InnerUtil.js +8 -2
package/package.json
CHANGED
package/src/InnerUtil.js
CHANGED
|
@@ -53,10 +53,16 @@ export default class InnerUtil {
|
|
|
53
53
|
let map = p.map ? p.map : MapView.Instance.map;
|
|
54
54
|
// 获取指北针元素
|
|
55
55
|
const compassElement = document.getElementById(p.compassId);
|
|
56
|
-
|
|
56
|
+
if (!compassElement) {
|
|
57
|
+
console.error("未获取到dom元素:" + p.compassId);
|
|
58
|
+
}
|
|
57
59
|
// 监听地图视图的旋转变化
|
|
58
60
|
map.getView().on('change:rotation', function () {
|
|
59
|
-
|
|
61
|
+
let compassIcon = document.getElementById(p.compassIconId);
|
|
62
|
+
if (!compassIcon) {
|
|
63
|
+
console.error("未获取到dom元素:" + p.compassIconId);
|
|
64
|
+
}
|
|
65
|
+
let rotation = map.getView().getRotation();
|
|
60
66
|
// 将弧度转换为角度,并更新指北针旋转
|
|
61
67
|
// 注意:PNG图片需要旋转相反方向,因为地图旋转时指北针应保持指向北方
|
|
62
68
|
const rotationDeg = -rotation * (180 / Math.PI);
|