cd-mapgis 1.0.68 → 1.0.69

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cd-mapgis",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "main": "./src/index.js",
5
5
  "types": "./src/index.d.ts",
6
6
  "type": "module",
package/src/InnerUtil.js CHANGED
@@ -64,8 +64,8 @@ export default class InnerUtil {
64
64
  }
65
65
  let rotation = map.getView().getRotation();
66
66
  // 将弧度转换为角度,并更新指北针旋转
67
- // 注意:PNG图片需要旋转相反方向,因为地图旋转时指北针应保持指向北方
68
- const rotationDeg = -rotation * (180 / Math.PI);
67
+ // 注意:PNG图片需要旋转方向,因为地图旋转时指北针应保持指向北方
68
+ const rotationDeg = rotation * (180 / Math.PI);
69
69
  compassIcon.style.transform = `rotate(${rotationDeg}deg)`;
70
70
  });
71
71
  // 点击指北针重置地图方向
package/src/MapView.js CHANGED
@@ -12,6 +12,7 @@ import * as OlInteraction from 'ol/interaction';
12
12
  */
13
13
  export default class MapView {
14
14
  static Instance = null;//主地图,一般用于只操作一个地图的情况
15
+ static CHINA_EXTENT = [73.66, 3.86, 135.05, 53.55];//中国范围
15
16
  constructor(p) {
16
17
  this.params = p;
17
18
  this.view = null;
@@ -59,6 +60,11 @@ export default class MapView {
59
60
  if (interactions) {
60
61
  viewP.interactions = interactions;
61
62
  }
63
+ if (p.chinaExtent) {
64
+ viewP.extent = MapView.CHINA_EXTENT;
65
+ viewP.constrainOnlyCenter = true;// 限制整个视图范围,而不仅仅是中心点
66
+ viewP.smoothExtentConstraint = interactions;// 平滑约束
67
+ }
62
68
  this.view = new View(viewP);
63
69
  }
64
70
  this.target = p.target ? p.target : 'map';//地图div的id