hn-map 1.1.0 → 1.1.2

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/dist/index.js CHANGED
@@ -420,7 +420,6 @@
420
420
  var _getMapRangeHeightByL = getMapRangeHeightByLevel(level),
421
421
  startHeight = _getMapRangeHeightByL.startHeight,
422
422
  endHeight = _getMapRangeHeightByL.endHeight;
423
- console.log("startHeight, endHeight:" + startHeight, endHeight);
424
423
  // 如果 startHeight 为 0(如 level=18),几何平均会为 0,不合理
425
424
  // 所以 level=18 特殊处理:返回 (0 + end)/2 或直接返回 end * 0.7 左右
426
425
  if (startHeight === 0) {
@@ -478,7 +477,7 @@
478
477
  this.event = {};
479
478
  this.level = null;
480
479
  this.layerList = [];
481
- this.level = 10;
480
+ this.level = this.option.level;
482
481
  deepMerge(this.option, option);
483
482
  this.config = this.formatConfig(this.option);
484
483
  this.map = new mars3d.Map(id, this.config);
@@ -5166,9 +5165,6 @@
5166
5165
  return fn[hnMap.mapType];
5167
5166
  });
5168
5167
 
5169
- /**
5170
- * HnMap类是一个地图工具类,用于创建和管理地图对象及其相关元素
5171
- */
5172
5168
  var HnMap = /*#__PURE__*/function () {
5173
5169
  /**
5174
5170
  * HnMap类的构造函数
@@ -5201,6 +5197,7 @@
5201
5197
  if (!HnMap.allowConstruction) {
5202
5198
  throw new Error("请使用 HnMap.create() 创建实例");
5203
5199
  }
5200
+ console.log(11111111111);
5204
5201
  this.id = id;
5205
5202
  this.option = option;
5206
5203
  this.mapType = mapType;
@@ -5282,7 +5279,7 @@
5282
5279
  return _context.a(3, 17);
5283
5280
  case 13:
5284
5281
  _context.n = 14;
5285
- return loadResource("https://map.sgcc.com.cn/maps?v=3.0.0", "js");
5282
+ return loadResource(option.sj_js_url, "js");
5286
5283
  case 14:
5287
5284
  _context.n = 15;
5288
5285
  return SGMap.tokenTask.login(option.sj_app_key, option.sj_app_secret);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hn-map",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "hn-map集成mars3d、高德、思极",
5
5
  "main": "dist/index.js",
6
6
  "author": "庞大仙",
package/src/index.ts CHANGED
@@ -18,6 +18,17 @@ import geoJson from "./layer/geoJson";
18
18
  /**
19
19
  * HnMap类是一个地图工具类,用于创建和管理地图对象及其相关元素
20
20
  */
21
+ interface option {
22
+ lng: number;
23
+ lat: number;
24
+ level: number;
25
+ pitch: number;
26
+ gaode_key: string;
27
+ sj_app_key: string;
28
+ sj_app_secret: string;
29
+ sj_js_url: string;
30
+ }
31
+
21
32
  export default class HnMap {
22
33
  id: any = null;
23
34
  option: any = null;
@@ -49,7 +60,7 @@ export default class HnMap {
49
60
  * @param mapType 地图的类型
50
61
  * @param map
51
62
  */
52
- private constructor(id: string, option: any, mapType: string, map: any) {
63
+ private constructor(id: string, option: option, mapType: string, map: any) {
53
64
  if (!HnMap.allowConstruction) {
54
65
  throw new Error("请使用 HnMap.create() 创建实例");
55
66
  }
@@ -65,7 +76,7 @@ export default class HnMap {
65
76
  * @param option 地图的配置选项
66
77
  * @param mapType 地图的类型
67
78
  */
68
- static async create(id: string, option: any, mapType: string) {
79
+ static async create(id: string, option: option, mapType: string) {
69
80
  // 判断是否在子路径下
70
81
  const basePath = window.location.pathname.endsWith("/")
71
82
  ? window.location.pathname
@@ -107,7 +118,7 @@ export default class HnMap {
107
118
  );
108
119
  break;
109
120
  case "siji":
110
- await loadResource("https://map.sgcc.com.cn/maps?v=3.0.0", "js");
121
+ await loadResource(option.sj_js_url, "js");
111
122
  await SGMap.tokenTask.login(option.sj_app_key, option.sj_app_secret);
112
123
  await SGMap.plugin([
113
124
  "SGMap.DrawPolygonHandler",
package/src/map.ts CHANGED
@@ -38,7 +38,7 @@ export default (hnMap: any) => {
38
38
 
39
39
  private constructor(id: string, option: any) {
40
40
  this.layerList = [];
41
- this.level = 10;
41
+ this.level = this.option.level;
42
42
  deepMerge(this.option, option);
43
43
  this.config = this.formatConfig(this.option);
44
44
  this.map = new mars3d.Map(id, this.config);
package/src/util.ts CHANGED
@@ -173,7 +173,6 @@ export function getMapRangeHeightByLevel(level: number) {
173
173
  */
174
174
  export function getLevelMiddleHeight(level: number): number {
175
175
  const {startHeight, endHeight} = getMapRangeHeightByLevel(level)
176
- console.log("startHeight, endHeight:"+startHeight, endHeight)
177
176
  // 如果 startHeight 为 0(如 level=18),几何平均会为 0,不合理
178
177
  // 所以 level=18 特殊处理:返回 (0 + end)/2 或直接返回 end * 0.7 左右
179
178
  if (startHeight === 0) {