@hzab/map-combine 0.4.2-alpha.8 → 0.4.2-alpha.9

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": "@hzab/map-combine",
3
- "version": "0.4.2-alpha.8",
3
+ "version": "0.4.2-alpha.9",
4
4
  "description": "地图组件",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -91,7 +91,7 @@ export class CesiumMap extends MapCombine {
91
91
 
92
92
  constructor(viewer?: any) {
93
93
  super();
94
- this._initParamsEvent(viewer);
94
+ viewer && this._initParamsEvent(viewer);
95
95
  }
96
96
 
97
97
  init(opt) {
@@ -44,8 +44,59 @@ export class MineMap extends MapCombine {
44
44
  this.viewer.setZoom(val);
45
45
  }
46
46
 
47
- constructor(viewer: any) {
47
+ constructor(viewer?: any) {
48
48
  super();
49
+ viewer && this._initParamsEvent(viewer);
50
+ }
51
+
52
+ init(opt) {
53
+ const {
54
+ container,
55
+ url,
56
+ minZoom = 4,
57
+ maxZoom = 18,
58
+ center = [120.2288892, 30.2349677, 0],
59
+ zoom = 13,
60
+ ...options
61
+ } = opt || {};
62
+ this.viewer = new minemap.Map({
63
+ container: container,
64
+ style: {
65
+ version: 8,
66
+ sources: {
67
+ tilemap: {
68
+ type: "raster",
69
+ tiles: [url],
70
+ tileSize: 256,
71
+ },
72
+ },
73
+ layers: [
74
+ {
75
+ id: "tilemap",
76
+ type: "raster",
77
+ source: "tilemap",
78
+ minzoom: 0,
79
+ maxzoom: 22,
80
+ layout: { visibility: "visible" },
81
+ },
82
+ ],
83
+ },
84
+ doubleClickZoom: false,
85
+ center,
86
+ zoom,
87
+ pitch: 0,
88
+ maxZoom,
89
+ minZoom,
90
+ ...options,
91
+ });
92
+ this._initParamsEvent(this.viewer);
93
+ return this.viewer;
94
+ }
95
+
96
+ _initParamsEvent(viewer) {
97
+ if (!viewer) {
98
+ return;
99
+ }
49
100
  this.viewer = viewer;
50
101
  this.container = viewer.getContainer();
51
102
  this.container.children.item(1).appendChild(this.htmllayer);