hn-map 1.1.5 → 1.1.7

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
@@ -442,6 +442,25 @@
442
442
  // 限制在 1~18
443
443
  return Math.max(1, Math.min(18, level));
444
444
  }
445
+ // 將坐标数组中的元素字符串类型统一处理为number类型
446
+ function convertPosition(position) {
447
+ return position.map(function (item) {
448
+ if (Array.isArray(item)) {
449
+ return item.map(function (innerItem) {
450
+ if (Array.isArray(innerItem)) {
451
+ // 第三层,将每个字符串转数字
452
+ return innerItem.map(function (str) {
453
+ return Number(str);
454
+ });
455
+ } else {
456
+ return Number(innerItem);
457
+ }
458
+ });
459
+ } else {
460
+ return Number(item);
461
+ }
462
+ });
463
+ }
445
464
 
446
465
  var map = (function (hnMap) {
447
466
  var defaultOption = {
@@ -463,7 +482,8 @@
463
482
  // 思极key
464
483
  sj_app_key: "",
465
484
  sj_app_secret: "",
466
- sj_style: "aegis://styles/aegis/Streets-Raster512"
485
+ sj_style: "aegis://styles/aegis/Streets-Raster512",
486
+ sj_route_net: true
467
487
  };
468
488
  var mars3d_map = /*#__PURE__*/function () {
469
489
  function mars3d_map(id, option) {
@@ -937,10 +957,12 @@
937
957
  return new Promise(function (resolve) {
938
958
  instance.map.on("load", function (e) {
939
959
  // 路况展示
940
- var roadNetLayer = new SGMap.RoadNetLayer({
941
- map: instance.map
942
- });
943
- roadNetLayer.render();
960
+ if (option.sj_route_net) {
961
+ var roadNetLayer = new SGMap.RoadNetLayer({
962
+ map: instance.map
963
+ });
964
+ roadNetLayer.render();
965
+ }
944
966
  //添加天空图层
945
967
  instance.map.addLayer({
946
968
  "id": "sky",
@@ -1029,7 +1051,12 @@
1029
1051
  key: "removeEntity",
1030
1052
  value: function removeEntity(entityParam) {
1031
1053
  var entity = this.getEntity(entityParam);
1054
+ console.log("removeEntity", entity);
1032
1055
  if (entity) {
1056
+ this.children = this.children.filter(function (v) {
1057
+ return v.id !== entity.id;
1058
+ });
1059
+ console.log("layerEntity", this.layerEntity);
1033
1060
  this.layerEntity.removeGraphic(entity.graphic);
1034
1061
  }
1035
1062
  }
@@ -1303,6 +1330,7 @@
1303
1330
  }, {
1304
1331
  key: "updateEntity",
1305
1332
  value: function updateEntity(entity, viewPos) {
1333
+ console.log("updateEntity", entity, viewPos);
1306
1334
  var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
1307
1335
  if (isUpdateEntity) {
1308
1336
  if (!entity.show && this.isIncludesLabel(entity.option.position, viewPos)) {
@@ -1357,8 +1385,10 @@
1357
1385
  key: "addLevelEntity",
1358
1386
  value: function addLevelEntity(entity) {
1359
1387
  if (entity.type == "imagePoint") {
1388
+ console.log("addLevelEntity=====", entity);
1360
1389
  hnMap.map.map.loadImage(entity.option.image, function (error, image) {
1361
1390
  entity.config.layout["icon-size"] = entity.option.width / image.width;
1391
+ entity.config.layout["icon-offset"] = [entity.option.offset[0] / entity.config.layout["icon-size"], entity.option.offset[1] / entity.config.layout["icon-size"]];
1362
1392
  hnMap.map.map.addImage(entity.id + "_image", image);
1363
1393
  hnMap.map.map.addLayer(entity.config);
1364
1394
  });
@@ -1371,7 +1401,7 @@
1371
1401
  var featureArr = {
1372
1402
  type: "Feature",
1373
1403
  properties: {
1374
- centerPoint: entity.option.position,
1404
+ centerPoint: convertPosition(entity.option.position),
1375
1405
  radius: entity.option.radius
1376
1406
  },
1377
1407
  geometry: {
@@ -1749,10 +1779,12 @@
1749
1779
  if (this.option.center) {
1750
1780
  center = this.option.center;
1751
1781
  } else {
1752
- if (this.type == "line" || this.type == "dash" || this.type == "flicker" || this.type == "flow" || this.type == "arrow" || this.type == "mapLabel" || this.type == "polygon" || this.type == "rectangle") {
1782
+ if (this.type == "line" || this.type == "dash" || this.type == "flicker" || this.type == "flow" || this.type == "arrow" || this.type == "mapLabel" || this.type == "rectangle") {
1753
1783
  center = this.option.position[0];
1754
1784
  } else if (this.type == "route") {
1755
1785
  center = [this.option.position[0][0], this.option.position[0][1]];
1786
+ } else if (this.type == "polygon") {
1787
+ center = this.option.position[0][0];
1756
1788
  } else {
1757
1789
  center = this.option.position;
1758
1790
  }
@@ -1966,13 +1998,11 @@
1966
1998
  type: "Feature",
1967
1999
  geometry: {
1968
2000
  type: "Point",
1969
- coordinates: option.position.map(function (num) {
1970
- return Number(num);
1971
- })
2001
+ coordinates: convertPosition(option.position)
1972
2002
  },
1973
- properties: Object.assign({
1974
- id: option.id
1975
- }, option.data)
2003
+ properties: {
2004
+ name: option.text
2005
+ }
1976
2006
  }]
1977
2007
  }
1978
2008
  },
@@ -1980,13 +2010,24 @@
1980
2010
  "circle-opacity": Number(option.opacity),
1981
2011
  "circle-radius": Number(option.size),
1982
2012
  "circle-color": option.color,
1983
- "circle-stroke-color": option.outlineColor,
1984
- "circle-stroke-width": option.outlineWidth,
1985
- "circle-stroke-opacity": Number(option.outlineOpacity) // 边框样式
2013
+ "circle-stroke-color": option.outline ? option.outlineColor : "transparent",
2014
+ "circle-stroke-width": option.outline ? Number(option.outlineWidth) : 0,
2015
+ "circle-stroke-opacity": option.outline ? Number(option.outlineOpacity) : 1 // 边框样式
1986
2016
  } // 填充样式
1987
2017
  };
1988
2018
  return config;
1989
2019
  }
2020
+ /**
2021
+ * 将 pixelOffset 转换为 text-offset (ems)
2022
+ * @param {Array<number>} pixelOffset - [x, y] 像素偏移
2023
+ * @param {number} textSizePx - 字体大小(px)
2024
+ * @returns {Array<number>} text-offset in ems
2025
+ */
2026
+ }, {
2027
+ key: "pixelOffsetToTextOffset",
2028
+ value: function pixelOffsetToTextOffset(pixelOffset, textSizePx) {
2029
+ return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
2030
+ }
1990
2031
  }, {
1991
2032
  key: "set",
1992
2033
  value: function set(option) {
@@ -2003,9 +2044,7 @@
2003
2044
  },
2004
2045
  geometry: {
2005
2046
  type: "Point",
2006
- coordinates: this.option.position.map(function (num) {
2007
- return Number(num);
2008
- })
2047
+ coordinates: convertPosition(this.option.position)
2009
2048
  }
2010
2049
  }]
2011
2050
  });
@@ -2015,7 +2054,7 @@
2015
2054
  for (var key2 in this.config[key]) {
2016
2055
  if (this.config[key].hasOwnProperty(key2)) {
2017
2056
  // 遍历 paint 属性
2018
- hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" || key2 == "circle-stroke-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
2057
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" || key2 == "circle-radius" || key2 == "circle-stroke-opacity" || key2 == "circle-stroke-width" || key2 == "text-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
2019
2058
  }
2020
2059
  }
2021
2060
  }
@@ -2173,9 +2212,7 @@
2173
2212
  type: "Feature",
2174
2213
  geometry: {
2175
2214
  type: "Point",
2176
- coordinates: option.position.map(function (num) {
2177
- return Number(num);
2178
- })
2215
+ coordinates: convertPosition(option.position)
2179
2216
  },
2180
2217
  properties: {
2181
2218
  name: option.text
@@ -2206,9 +2243,7 @@
2206
2243
  type: "Feature",
2207
2244
  geometry: {
2208
2245
  type: "Point",
2209
- coordinates: option.position.map(function (num) {
2210
- return Number(num);
2211
- })
2246
+ coordinates: convertPosition(option.position)
2212
2247
  },
2213
2248
  properties: {
2214
2249
  name: option.num
@@ -2492,9 +2527,7 @@
2492
2527
  type: "Feature",
2493
2528
  geometry: {
2494
2529
  type: "Point",
2495
- coordinates: option.position.map(function (num) {
2496
- return Number(num);
2497
- })
2530
+ coordinates: convertPosition(option.position)
2498
2531
  },
2499
2532
  properties: {
2500
2533
  name: option.text
@@ -2504,15 +2537,17 @@
2504
2537
  },
2505
2538
  layout: {
2506
2539
  "icon-image": option.id + "_image",
2507
- "icon-size": 1,
2508
- "icon-ignore-placement": true,
2509
- "text-ignore-placement": true,
2540
+ // "icon-size": 1,
2541
+ "icon-ignore-placement": false,
2542
+ // "icon-offset": convertPosition(option.offset),
2543
+ "text-ignore-placement": false,
2544
+ //
2510
2545
  "text-field": "{name}",
2511
2546
  // 文本
2512
- "text-size": option.fontSize,
2513
- "text-anchor": "top",
2514
- "icon-anchor": "center",
2515
- "text-offset": option.offset
2547
+ "text-size": Number(option.fontSize),
2548
+ "text-anchor": option.verticalOrigin,
2549
+ "icon-anchor": option.verticalOrigin
2550
+ // "text-offset": convertPosition(option.offset),
2516
2551
  },
2517
2552
  paint: {
2518
2553
  "text-color": option.color
@@ -2525,16 +2560,20 @@
2525
2560
  value: function set(option) {
2526
2561
  deepMerge(this.option, option);
2527
2562
  this.config = this.formatConfig(this.option);
2563
+ console.log(this.config, "======CONFIG=====");
2564
+ console.log(this.option, "=========OPTION");
2528
2565
  var mySource = hnMap.map.map.getSource(this.config.id);
2566
+ console.log(mySource, "=========SOURCE");
2529
2567
  mySource.setData({
2530
2568
  type: "FeatureCollection",
2531
2569
  features: [{
2532
2570
  type: "Feature",
2533
2571
  geometry: {
2534
2572
  type: "Point",
2535
- coordinates: this.option.position.map(function (num) {
2536
- return Number(num);
2537
- })
2573
+ coordinates: convertPosition(this.option.position)
2574
+ },
2575
+ properties: {
2576
+ name: this.option.text
2538
2577
  }
2539
2578
  }]
2540
2579
  });
@@ -2544,7 +2583,7 @@
2544
2583
  for (var key2 in this.config[key]) {
2545
2584
  if (this.config[key].hasOwnProperty(key2)) {
2546
2585
  // 遍历 layout 属性
2547
- hnMap.map.map.setLayoutProperty(this.config.id, key2, this.config[key][key2]);
2586
+ hnMap.map.map.setLayoutProperty(this.config.id, key2, key2 == "text-size" ? Number(this.config[key][key2]) : this.config[key][key2]);
2548
2587
  }
2549
2588
  }
2550
2589
  }
@@ -2777,7 +2816,7 @@
2777
2816
  outlineColor: option.outlineColor,
2778
2817
  outlineWidth: option.outlineWidth,
2779
2818
  outlineOpacity: option.outlineOpacity,
2780
- pixelOffset: option.offset,
2819
+ pixelOffset: convertPosition(option.offset),
2781
2820
  scaleByDistance: option.scaleByDistance,
2782
2821
  clampToGround: !option.position[2],
2783
2822
  distanceDisplayCondition: option.distanceDisplayCondition,
@@ -2920,9 +2959,12 @@
2920
2959
  // 文本样式
2921
2960
  paint: {
2922
2961
  "text-color": option.color,
2923
- "text-halo-color": option.outlineColor,
2962
+ "text-halo-color": option.outline ? option.outlineColor : "transparent",
2924
2963
  // 文字外边线颜色
2925
- "text-halo-width": option.outlineWidth // 文字外边线宽度
2964
+ "text-halo-width": option.outline ? Number(option.outlineWidth) : 0,
2965
+ // 文字外边线宽度
2966
+ "text-opacity": Number(option.opacity)
2967
+ // "text-halo-opacity": option.outline ? option.outlineOpacity : 1,
2926
2968
  } // 填充样式
2927
2969
  };
2928
2970
  if (option.type === "label") {
@@ -2930,9 +2972,7 @@
2930
2972
  type: "Feature",
2931
2973
  geometry: {
2932
2974
  type: "Point",
2933
- coordinates: option.position.map(function (num) {
2934
- return Number(num);
2935
- })
2975
+ coordinates: convertPosition(option.position)
2936
2976
  },
2937
2977
  properties: {
2938
2978
  name: option.text
@@ -2947,7 +2987,7 @@
2947
2987
  },
2948
2988
  geometry: {
2949
2989
  type: "Point",
2950
- coordinates: item
2990
+ coordinates: convertPosition(option.position)
2951
2991
  }
2952
2992
  });
2953
2993
  });
@@ -2982,9 +3022,7 @@
2982
3022
  },
2983
3023
  geometry: {
2984
3024
  type: "Point",
2985
- coordinates: this.option.position.map(function (num) {
2986
- return Number(num);
2987
- })
3025
+ coordinates: convertPosition(option.position)
2988
3026
  }
2989
3027
  }]
2990
3028
  });
@@ -3014,7 +3052,7 @@
3014
3052
  for (var key2 in this.config[key]) {
3015
3053
  if (this.config[key].hasOwnProperty(key2)) {
3016
3054
  // 遍历 paint 属性
3017
- hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "text-halo-width" ? Number(this.config[key][key2]) : this.config[key][key2]);
3055
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "text-halo-width" || key2 == "text-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
3018
3056
  }
3019
3057
  }
3020
3058
  }
@@ -3285,7 +3323,7 @@
3285
3323
  type: "Feature",
3286
3324
  geometry: {
3287
3325
  type: "LineString",
3288
- coordinates: option.position
3326
+ coordinates: convertPosition(option.position)
3289
3327
  },
3290
3328
  properties: Object.assign({
3291
3329
  id: option.id
@@ -3295,12 +3333,14 @@
3295
3333
  },
3296
3334
  layout: {
3297
3335
  "line-cap": "round",
3298
- "line-join": "round"
3336
+ // 线端点样式
3337
+ "line-join": "round" // 线连接样式
3299
3338
  },
3300
3339
  paint: {
3301
3340
  "line-color": option.type == "dash" ? option.dashColor : option.color,
3302
3341
  "line-width": Number(option.width),
3303
3342
  "line-opacity": Number(option.opacity)
3343
+ // "line-gap-width": 4,
3304
3344
  }
3305
3345
  };
3306
3346
  var isShow = true;
@@ -3321,6 +3361,20 @@
3321
3361
  value: function set(option) {
3322
3362
  deepMerge(this.option, option);
3323
3363
  this.config = this.formatConfig(this.option);
3364
+ var mySource = hnMap.map.map.getSource(this.config.id);
3365
+ mySource.setData({
3366
+ type: "FeatureCollection",
3367
+ features: [{
3368
+ type: "Feature",
3369
+ properties: Object.assign({
3370
+ id: option.id
3371
+ }, option.data),
3372
+ geometry: {
3373
+ type: "LineString",
3374
+ coordinates: convertPosition(this.option.position)
3375
+ }
3376
+ }]
3377
+ });
3324
3378
  for (var key in this.config) {
3325
3379
  if (this.config.hasOwnProperty(key)) {
3326
3380
  if (key == "paint") {
@@ -3548,7 +3602,7 @@
3548
3602
  // 允许调整圆心
3549
3603
  canMove: false,
3550
3604
  // 设置非编辑状态下的图层颜色
3551
- drawColor: option.outlineColor,
3605
+ // drawColor: option.outlineColor,
3552
3606
  // 设置编辑状态下的图层颜色
3553
3607
  // editColor: "red",
3554
3608
  style: {
@@ -3556,7 +3610,13 @@
3556
3610
  polygon: {
3557
3611
  "fill-color": option.color,
3558
3612
  // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3559
- "fill-opacity": Number(option.opacity)
3613
+ "fill-opacity": Number(option.opacity),
3614
+ "fill-outline-color": option.outlineColor
3615
+ },
3616
+ polyline: {
3617
+ "line-color": option.outlineColor,
3618
+ "line-opacity": Number(option.outlineOpacity),
3619
+ "line-width": Number(option.outlineWidth)
3560
3620
  }
3561
3621
  },
3562
3622
  // 编辑数据
@@ -3575,8 +3635,8 @@
3575
3635
  var featureArr = {
3576
3636
  type: "Feature",
3577
3637
  properties: {
3578
- centerPoint: option.position,
3579
- radius: option.radius
3638
+ centerPoint: convertPosition(this.option.position),
3639
+ radius: this.option.radius
3580
3640
  },
3581
3641
  geometry: {
3582
3642
  type: "Polygon",
@@ -3727,7 +3787,6 @@
3727
3787
  key: "formatConfig",
3728
3788
  value: function formatConfig(option) {
3729
3789
  var RectanglePosition = createRectangleCoordinates(option.position[0], option.position[1]);
3730
- console.log([RectanglePosition], "========RectanglePosition=======");
3731
3790
  var config = {
3732
3791
  id: option.id,
3733
3792
  type: "fill",
@@ -3747,7 +3806,9 @@
3747
3806
  paint: {
3748
3807
  "fill-color": option.color,
3749
3808
  // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3750
- "fill-opacity": Number(option.opacity)
3809
+ "fill-opacity": Number(option.opacity),
3810
+ "fill-antialias": true,
3811
+ "fill-outline-color": option.outlineColor
3751
3812
  }
3752
3813
  };
3753
3814
  return config;
@@ -3931,7 +3992,7 @@
3931
3992
  type: "Feature",
3932
3993
  geometry: {
3933
3994
  type: "Polygon",
3934
- coordinates: option.position
3995
+ coordinates: convertPosition(option.position)
3935
3996
  }
3936
3997
  }]
3937
3998
  }
@@ -3939,7 +4000,9 @@
3939
4000
  paint: {
3940
4001
  "fill-color": option.color,
3941
4002
  // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3942
- "fill-opacity": Number(option.opacity)
4003
+ "fill-opacity": Number(option.opacity),
4004
+ "fill-antialias": true,
4005
+ "fill-outline-color": option.outlineColor
3943
4006
  }
3944
4007
  };
3945
4008
  return config;
@@ -3956,7 +4019,7 @@
3956
4019
  type: "Feature",
3957
4020
  geometry: {
3958
4021
  type: "Polygon",
3959
- coordinates: [option.position] //三层数组[[[0,0],[0,0]]]
4022
+ coordinates: convertPosition(option.position) //三层数组[[[0,0],[0,0]]]
3960
4023
  }
3961
4024
  }]
3962
4025
  });
@@ -5333,7 +5396,6 @@
5333
5396
  case 0:
5334
5397
  // 判断是否在子路径下
5335
5398
  basePath = window.location.pathname.endsWith("/") ? window.location.pathname : window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
5336
- console.log(basePath);
5337
5399
  _context.n = 1;
5338
5400
  return loadResource(basePath + "lib/turf/turf.min.js", "js");
5339
5401
  case 1:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hn-map",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "hn-map集成mars3d、高德、思极",
5
5
  "main": "dist/index.js",
6
6
  "author": "庞大仙",
@@ -82,12 +82,13 @@ export default class siji_entity {
82
82
  this.type == "flow" ||
83
83
  this.type == "arrow" ||
84
84
  this.type == "mapLabel" ||
85
- this.type == "polygon" ||
86
85
  this.type == "rectangle"
87
86
  ) {
88
87
  center = this.option.position[0];
89
88
  } else if (this.type == "route") {
90
89
  center = [this.option.position[0][0], this.option.position[0][1]];
90
+ } else if (this.type == "polygon") {
91
+ center = this.option.position[0][0];
91
92
  } else {
92
93
  center = this.option.position;
93
94
  }
@@ -1,4 +1,9 @@
1
- import { deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format } from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -177,7 +182,7 @@ export default (hnMap: any) => {
177
182
  // 允许调整圆心
178
183
  canMove: false,
179
184
  // 设置非编辑状态下的图层颜色
180
- drawColor: option.outlineColor,
185
+ // drawColor: option.outlineColor,
181
186
  // 设置编辑状态下的图层颜色
182
187
  // editColor: "red",
183
188
  style: {
@@ -185,6 +190,12 @@ export default (hnMap: any) => {
185
190
  polygon: {
186
191
  "fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
187
192
  "fill-opacity": Number(option.opacity),
193
+ "fill-outline-color": option.outlineColor,
194
+ },
195
+ polyline: {
196
+ "line-color": option.outlineColor,
197
+ "line-opacity": Number(option.outlineOpacity),
198
+ "line-width": Number(option.outlineWidth),
188
199
  },
189
200
  },
190
201
  // 编辑数据
@@ -202,8 +213,8 @@ export default (hnMap: any) => {
202
213
  let featureArr = {
203
214
  type: "Feature",
204
215
  properties: {
205
- centerPoint: option.position,
206
- radius: option.radius,
216
+ centerPoint: convertPosition(this.option.position),
217
+ radius: this.option.radius,
207
218
  },
208
219
  geometry: {
209
220
  type: "Polygon",
@@ -1,4 +1,9 @@
1
- import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -45,8 +50,12 @@ export default (hnMap: any) => {
45
50
  }
46
51
 
47
52
  formatConfig(option: any) {
48
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
49
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
53
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
54
+ option.distanceDisplayCondition_far
55
+ );
56
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
57
+ option.distanceDisplayCondition_near
58
+ );
50
59
  return {
51
60
  id: option.id,
52
61
  position: option.position,
@@ -1,4 +1,9 @@
1
- import { deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format } from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -178,7 +183,7 @@ export default (hnMap: any) => {
178
183
  type: "Feature",
179
184
  geometry: {
180
185
  type: "Point",
181
- coordinates: option.position.map((num: any) => Number(num)),
186
+ coordinates: convertPosition(option.position),
182
187
  },
183
188
  properties: {
184
189
  name: option.text,
@@ -189,14 +194,15 @@ export default (hnMap: any) => {
189
194
  },
190
195
  layout: {
191
196
  "icon-image": option.id + "_image",
192
- "icon-size": 1,
193
- "icon-ignore-placement": true,
194
- "text-ignore-placement": true,
197
+ // "icon-size": 1,
198
+ "icon-ignore-placement": false,
199
+ // "icon-offset": convertPosition(option.offset),
200
+ "text-ignore-placement": false, //
195
201
  "text-field": "{name}", // 文本
196
- "text-size": option.fontSize,
197
- "text-anchor": "top",
198
- "icon-anchor": "center",
199
- "text-offset": option.offset,
202
+ "text-size": Number(option.fontSize),
203
+ "text-anchor": option.verticalOrigin,
204
+ "icon-anchor": option.verticalOrigin,
205
+ // "text-offset": convertPosition(option.offset),
200
206
  },
201
207
  paint: {
202
208
  "text-color": option.color,
@@ -208,7 +214,10 @@ export default (hnMap: any) => {
208
214
  set(option: any) {
209
215
  deepMerge(this.option, option);
210
216
  this.config = this.formatConfig(this.option);
217
+ console.log(this.config, "======CONFIG=====");
218
+ console.log(this.option, "=========OPTION");
211
219
  let mySource = hnMap.map.map.getSource(this.config.id);
220
+ console.log(mySource, "=========SOURCE");
212
221
  mySource.setData({
213
222
  type: "FeatureCollection",
214
223
  features: [
@@ -216,7 +225,10 @@ export default (hnMap: any) => {
216
225
  type: "Feature",
217
226
  geometry: {
218
227
  type: "Point",
219
- coordinates: this.option.position.map((num: any) => Number(num)),
228
+ coordinates: convertPosition(this.option.position),
229
+ },
230
+ properties: {
231
+ name: this.option.text,
220
232
  },
221
233
  },
222
234
  ],
@@ -231,7 +243,9 @@ export default (hnMap: any) => {
231
243
  hnMap.map.map.setLayoutProperty(
232
244
  this.config.id,
233
245
  key2,
234
- this.config[key][key2]
246
+ key2 == "text-size"
247
+ ? Number(this.config[key][key2])
248
+ : this.config[key][key2]
235
249
  );
236
250
  }
237
251
  }
@@ -1,4 +1,9 @@
1
- import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -54,8 +59,12 @@ export default (hnMap: any) => {
54
59
  option.position[1],
55
60
  option.position[2] || 0
56
61
  );
57
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
58
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
62
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
63
+ option.distanceDisplayCondition_far
64
+ );
65
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
66
+ option.distanceDisplayCondition_near
67
+ );
59
68
  return {
60
69
  id: option.id,
61
70
  position: position,
@@ -69,7 +78,7 @@ export default (hnMap: any) => {
69
78
  outlineColor: option.outlineColor,
70
79
  outlineWidth: option.outlineWidth,
71
80
  outlineOpacity: option.outlineOpacity,
72
- pixelOffset: option.offset,
81
+ pixelOffset: convertPosition(option.offset),
73
82
  scaleByDistance: option.scaleByDistance,
74
83
  clampToGround: !option.position[2],
75
84
  distanceDisplayCondition: option.distanceDisplayCondition,
@@ -199,14 +208,21 @@ export default (hnMap: any) => {
199
208
  "text-field": "{name}",
200
209
  "text-size": Number(option.fontSize),
201
210
  "text-anchor": "top", // 顶部对齐
202
- "text-offset": this.pixelOffsetToTextOffset(option.offset,option.fontSize),
211
+ "text-offset": this.pixelOffsetToTextOffset(
212
+ option.offset,
213
+ option.fontSize
214
+ ),
203
215
  "text-max-width": 8,
204
216
  "text-font": ["Microsoft YaHei Regular"],
205
217
  }, // 文本样式
206
218
  paint: {
207
219
  "text-color": option.color,
208
- "text-halo-color": option.outlineColor, // 文字外边线颜色
209
- "text-halo-width": option.outlineWidth, // 文字外边线宽度
220
+ "text-halo-color": option.outline
221
+ ? option.outlineColor
222
+ : "transparent", // 文字外边线颜色
223
+ "text-halo-width": option.outline ? Number(option.outlineWidth) : 0, // 文字外边线宽度
224
+ "text-opacity": Number(option.opacity),
225
+ // "text-halo-opacity": option.outline ? option.outlineOpacity : 1,
210
226
  }, // 填充样式
211
227
  };
212
228
  if (option.type === "label") {
@@ -214,7 +230,7 @@ export default (hnMap: any) => {
214
230
  type: "Feature",
215
231
  geometry: {
216
232
  type: "Point",
217
- coordinates: option.position.map((num:any)=>Number(num)),
233
+ coordinates: convertPosition(option.position),
218
234
  },
219
235
  properties: {
220
236
  name: option.text,
@@ -227,7 +243,7 @@ export default (hnMap: any) => {
227
243
  properties: { name: option.text },
228
244
  geometry: {
229
245
  type: "Point",
230
- coordinates: item,
246
+ coordinates: convertPosition(option.position),
231
247
  },
232
248
  });
233
249
  });
@@ -242,11 +258,8 @@ export default (hnMap: any) => {
242
258
  * @param {number} textSizePx - 字体大小(px)
243
259
  * @returns {Array<number>} text-offset in ems
244
260
  */
245
- pixelOffsetToTextOffset(pixelOffset:any, textSizePx:any): Array<number> {
246
- return [
247
- pixelOffset[0] / textSizePx,
248
- pixelOffset[1] / textSizePx
249
- ];
261
+ pixelOffsetToTextOffset(pixelOffset: any, textSizePx: any): Array<number> {
262
+ return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
250
263
  }
251
264
 
252
265
  set(option: any) {
@@ -262,7 +275,7 @@ export default (hnMap: any) => {
262
275
  properties: { name: this.option.text },
263
276
  geometry: {
264
277
  type: "Point",
265
- coordinates: this.option.position.map((num:any)=>Number(num)),
278
+ coordinates: convertPosition(option.position),
266
279
  },
267
280
  },
268
281
  ],
@@ -294,7 +307,7 @@ export default (hnMap: any) => {
294
307
  hnMap.map.map.setPaintProperty(
295
308
  this.config.id,
296
309
  key2,
297
- key2 == "text-halo-width"
310
+ key2 == "text-halo-width" || key2 == "text-opacity"
298
311
  ? Number(this.config[key][key2])
299
312
  : this.config[key][key2]
300
313
  );
@@ -1,4 +1,9 @@
1
- import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -50,8 +55,12 @@ export default (hnMap: any) => {
50
55
 
51
56
  formatConfig(option: any) {
52
57
  let config: any = {};
53
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
54
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
58
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
59
+ option.distanceDisplayCondition_far
60
+ );
61
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
62
+ option.distanceDisplayCondition_near
63
+ );
55
64
  if (option.combine) {
56
65
  config = {
57
66
  id: option.id,
@@ -233,7 +242,7 @@ export default (hnMap: any) => {
233
242
  type: "Feature",
234
243
  geometry: {
235
244
  type: "LineString",
236
- coordinates: option.position,
245
+ coordinates: convertPosition(option.position),
237
246
  },
238
247
  properties: {
239
248
  id: option.id,
@@ -244,13 +253,14 @@ export default (hnMap: any) => {
244
253
  },
245
254
  },
246
255
  layout: {
247
- "line-cap": "round",
248
- "line-join": "round",
256
+ "line-cap": "round", // 线端点样式
257
+ "line-join": "round", // 线连接样式
249
258
  },
250
259
  paint: {
251
260
  "line-color": option.type == "dash" ? option.dashColor : option.color,
252
261
  "line-width": Number(option.width),
253
262
  "line-opacity": Number(option.opacity),
263
+ // "line-gap-width": 4,
254
264
  },
255
265
  };
256
266
  let isShow: boolean = true;
@@ -279,6 +289,25 @@ export default (hnMap: any) => {
279
289
  set(option: any) {
280
290
  deepMerge(this.option, option);
281
291
  this.config = this.formatConfig(this.option);
292
+
293
+ let mySource = hnMap.map.map.getSource(this.config.id);
294
+ mySource.setData({
295
+ type: "FeatureCollection",
296
+ features: [
297
+ {
298
+ type: "Feature",
299
+ properties: {
300
+ id: option.id,
301
+ ...option.data,
302
+ },
303
+ geometry: {
304
+ type: "LineString",
305
+ coordinates: convertPosition(this.option.position),
306
+ },
307
+ },
308
+ ],
309
+ });
310
+
282
311
  for (let key in this.config) {
283
312
  if (this.config.hasOwnProperty(key)) {
284
313
  if (key == "paint") {
@@ -1,4 +1,9 @@
1
- import { deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format } from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -144,7 +149,7 @@ export default (hnMap: any) => {
144
149
  type: "Feature",
145
150
  geometry: {
146
151
  type: "Point",
147
- coordinates: option.position.map((num: any) => Number(num)),
152
+ coordinates: convertPosition(option.position),
148
153
  },
149
154
  properties: {
150
155
  name: option.text,
@@ -153,6 +158,7 @@ export default (hnMap: any) => {
153
158
  ],
154
159
  },
155
160
  },
161
+
156
162
  paint: {
157
163
  "circle-opacity": Number(option.opacity),
158
164
  "circle-radius": Number(option.size),
@@ -177,7 +183,7 @@ export default (hnMap: any) => {
177
183
  type: "Feature",
178
184
  geometry: {
179
185
  type: "Point",
180
- coordinates: option.position.map((num: any) => Number(num)),
186
+ coordinates: convertPosition(option.position),
181
187
  },
182
188
  properties: {
183
189
  name: option.num,
@@ -1,4 +1,9 @@
1
- import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -48,8 +53,12 @@ export default (hnMap: any) => {
48
53
  }
49
54
 
50
55
  formatConfig(option: any) {
51
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
52
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
56
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
57
+ option.distanceDisplayCondition_far
58
+ );
59
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
60
+ option.distanceDisplayCondition_near
61
+ );
53
62
  return {
54
63
  id: option.id,
55
64
  position: option.position,
@@ -162,29 +171,43 @@ export default (hnMap: any) => {
162
171
  type: "Feature",
163
172
  geometry: {
164
173
  type: "Point",
165
- coordinates: option.position.map((num:any)=>Number(num)),
174
+ coordinates: convertPosition(option.position),
166
175
  },
167
176
  properties: {
168
- id: option.id,
169
- ...option.data,
177
+ name: option.text,
170
178
  },
171
179
  },
172
180
  ],
173
181
  },
174
182
  },
183
+
175
184
  paint: {
176
185
  "circle-opacity": Number(option.opacity),
177
186
  "circle-radius": Number(option.size),
178
187
  "circle-color": option.color,
179
- "circle-stroke-color": option.outlineColor,
180
- "circle-stroke-width": option.outlineWidth,
181
- "circle-stroke-opacity": Number(option.outlineOpacity), // 边框样式
188
+ "circle-stroke-color": option.outline
189
+ ? option.outlineColor
190
+ : "transparent",
191
+ "circle-stroke-width": option.outline
192
+ ? Number(option.outlineWidth)
193
+ : 0,
194
+ "circle-stroke-opacity": option.outline
195
+ ? Number(option.outlineOpacity)
196
+ : 1, // 边框样式
182
197
  }, // 填充样式
183
198
  };
184
199
 
185
200
  return config;
186
201
  }
187
-
202
+ /**
203
+ * 将 pixelOffset 转换为 text-offset (ems)
204
+ * @param {Array<number>} pixelOffset - [x, y] 像素偏移
205
+ * @param {number} textSizePx - 字体大小(px)
206
+ * @returns {Array<number>} text-offset in ems
207
+ */
208
+ pixelOffsetToTextOffset(pixelOffset: any, textSizePx: any): Array<number> {
209
+ return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
210
+ }
188
211
  set(option: any) {
189
212
  console.log("=====set point====", option);
190
213
  deepMerge(this.option, option);
@@ -198,7 +221,7 @@ export default (hnMap: any) => {
198
221
  properties: { name: this.option.text },
199
222
  geometry: {
200
223
  type: "Point",
201
- coordinates: this.option.position.map((num:any)=>Number(num)),
224
+ coordinates: convertPosition(this.option.position),
202
225
  },
203
226
  },
204
227
  ],
@@ -212,7 +235,11 @@ export default (hnMap: any) => {
212
235
  hnMap.map.map.setPaintProperty(
213
236
  this.config.id,
214
237
  key2,
215
- key2 == "circle-opacity" || key2 == "circle-stroke-opacity"
238
+ key2 == "circle-opacity" ||
239
+ key2 == "circle-radius" ||
240
+ key2 == "circle-stroke-opacity" ||
241
+ key2 == "circle-stroke-width" ||
242
+ key2 == "text-opacity"
216
243
  ? Number(this.config[key][key2])
217
244
  : this.config[key][key2]
218
245
  );
@@ -1,4 +1,9 @@
1
- import {deepMerge, getLevelMiddleHeight, wgs84ToGcj02Format} from "../util";
1
+ import {
2
+ deepMerge,
3
+ getLevelMiddleHeight,
4
+ wgs84ToGcj02Format,
5
+ convertPosition,
6
+ } from "../util";
2
7
  import mars3d_entity from "../base/mars3d_entity";
3
8
  import gaode_entity from "../base/gaode_entity";
4
9
  import siji_entity from "../base/siji_entity";
@@ -35,8 +40,12 @@ export default (hnMap: any) => {
35
40
  }
36
41
 
37
42
  formatConfig(option: any) {
38
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
39
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
43
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
44
+ option.distanceDisplayCondition_far
45
+ );
46
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
47
+ option.distanceDisplayCondition_near
48
+ );
40
49
  return {
41
50
  id: option.id,
42
51
  positions: option.position,
@@ -129,7 +138,7 @@ export default (hnMap: any) => {
129
138
  type: "Feature",
130
139
  geometry: {
131
140
  type: "Polygon",
132
- coordinates: option.position,
141
+ coordinates: convertPosition(option.position),
133
142
  },
134
143
  },
135
144
  ],
@@ -139,6 +148,8 @@ export default (hnMap: any) => {
139
148
  paint: {
140
149
  "fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
141
150
  "fill-opacity": Number(option.opacity),
151
+ "fill-antialias": true,
152
+ "fill-outline-color": option.outlineColor,
142
153
  },
143
154
  };
144
155
  return config;
@@ -155,7 +166,7 @@ export default (hnMap: any) => {
155
166
  type: "Feature",
156
167
  geometry: {
157
168
  type: "Polygon",
158
- coordinates: [option.position], //三层数组[[[0,0],[0,0]]]
169
+ coordinates: convertPosition(option.position), //三层数组[[[0,0],[0,0]]]
159
170
  },
160
171
  },
161
172
  ],
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  deepMerge,
3
3
  wgs84ToGcj02Format,
4
- createRectangleCoordinates, getLevelMiddleHeight,
4
+ createRectangleCoordinates,
5
+ getLevelMiddleHeight,
5
6
  } from "../util";
6
7
  import mars3d_entity from "../base/mars3d_entity";
7
8
  import gaode_entity from "../base/gaode_entity";
@@ -39,8 +40,12 @@ export default (hnMap: any) => {
39
40
  }
40
41
 
41
42
  formatConfig(option: any) {
42
- const distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far)
43
- const distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near)
43
+ const distanceDisplayCondition_far = getLevelMiddleHeight(
44
+ option.distanceDisplayCondition_far
45
+ );
46
+ const distanceDisplayCondition_near = getLevelMiddleHeight(
47
+ option.distanceDisplayCondition_near
48
+ );
44
49
  return {
45
50
  id: option.id,
46
51
  positions: option.position,
@@ -127,7 +132,6 @@ export default (hnMap: any) => {
127
132
  option.position[0],
128
133
  option.position[1]
129
134
  );
130
- console.log([RectanglePosition], "========RectanglePosition=======");
131
135
  let config = {
132
136
  id: option.id,
133
137
  type: "fill",
@@ -150,6 +154,8 @@ export default (hnMap: any) => {
150
154
  paint: {
151
155
  "fill-color": option.color, // 填充颜色覆盖drawColor设置的颜色,呈现绿色
152
156
  "fill-opacity": Number(option.opacity),
157
+ "fill-antialias": true,
158
+ "fill-outline-color": option.outlineColor,
153
159
  },
154
160
  };
155
161
  return config;
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ interface option {
28
28
  sj_app_secret: string;
29
29
  sj_js_url: string;
30
30
  sj_style: string;
31
+ sj_route_net: boolean;
31
32
  }
32
33
 
33
34
  export default class HnMap {
@@ -1,4 +1,4 @@
1
- import { deepMerge } from "../util";
1
+ import { deepMerge, convertPosition } from "../util";
2
2
 
3
3
  export default (hnMap: any) => {
4
4
  const defaultOption = {};
@@ -41,7 +41,12 @@ export default (hnMap: any) => {
41
41
 
42
42
  removeEntity(entityParam: any) {
43
43
  const entity = this.getEntity(entityParam);
44
+ console.log("removeEntity", entity);
44
45
  if (entity) {
46
+ this.children = this.children.filter((v: any) => {
47
+ return v.id !== entity.id;
48
+ });
49
+ console.log("layerEntity", this.layerEntity);
45
50
  this.layerEntity.removeGraphic(entity.graphic);
46
51
  }
47
52
  }
@@ -276,6 +281,7 @@ export default (hnMap: any) => {
276
281
  }
277
282
 
278
283
  updateEntity(entity: any, viewPos: any) {
284
+ console.log("updateEntity", entity, viewPos);
279
285
  const isUpdateEntity =
280
286
  hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) &&
281
287
  hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
@@ -335,11 +341,17 @@ export default (hnMap: any) => {
335
341
 
336
342
  addLevelEntity(entity: any) {
337
343
  if (entity.type == "imagePoint") {
344
+ console.log("addLevelEntity=====", entity);
338
345
  hnMap.map.map.loadImage(
339
346
  entity.option.image,
340
347
  function (error: any, image: any) {
341
348
  entity.config.layout["icon-size"] =
342
349
  entity.option.width / image.width;
350
+ entity.config.layout["icon-offset"] = [
351
+ entity.option.offset[0] / entity.config.layout["icon-size"],
352
+ entity.option.offset[1] / entity.config.layout["icon-size"],
353
+ ];
354
+
343
355
  hnMap.map.map.addImage(entity.id + "_image", image);
344
356
  hnMap.map.map.addLayer(entity.config);
345
357
  }
@@ -353,7 +365,7 @@ export default (hnMap: any) => {
353
365
  let featureArr = {
354
366
  type: "Feature",
355
367
  properties: {
356
- centerPoint: entity.option.position,
368
+ centerPoint: convertPosition(entity.option.position),
357
369
  radius: entity.option.radius,
358
370
  },
359
371
  geometry: {
package/src/map.ts CHANGED
@@ -21,6 +21,7 @@ export default (hnMap: any) => {
21
21
  sj_app_key: "",
22
22
  sj_app_secret: "",
23
23
  sj_style: "aegis://styles/aegis/Streets-Raster512",
24
+ sj_route_net:true,
24
25
  };
25
26
 
26
27
  class mars3d_map {
@@ -286,8 +287,11 @@ export default (hnMap: any) => {
286
287
  await new Promise((resolve) => {
287
288
  instance.map.on("load", (e: any) => {
288
289
  // 路况展示
289
- let roadNetLayer = new SGMap.RoadNetLayer({ map: instance.map });
290
- roadNetLayer.render();
290
+ if(option.sj_route_net){
291
+ let roadNetLayer = new SGMap.RoadNetLayer({ map: instance.map });
292
+ roadNetLayer.render();
293
+ }
294
+
291
295
  //添加天空图层
292
296
  instance.map.addLayer({
293
297
  "id": "sky",
package/src/util.ts CHANGED
@@ -215,11 +215,20 @@ export function getHeightToLevel(height: number): number {
215
215
  }
216
216
  // 將坐标数组中的元素字符串类型统一处理为number类型
217
217
  export function convertPosition(
218
- position: string[] | string[][]
219
- ): number[] | number[][] {
220
- return position.map((item) =>
221
- Array.isArray(item)
222
- ? (item as string[]).map((str) => Number(str))
223
- : Number(item)
224
- ) as number[] | number[][];
218
+ position: string[] | string[][] | string[][][]
219
+ ): number[] | number[][] | number[][][] {
220
+ return position.map((item) => {
221
+ if (Array.isArray(item)) {
222
+ return item.map((innerItem) => {
223
+ if (Array.isArray(innerItem)) {
224
+ // 第三层,将每个字符串转数字
225
+ return innerItem.map((str) => Number(str));
226
+ } else {
227
+ return Number(innerItem);
228
+ }
229
+ });
230
+ } else {
231
+ return Number(item);
232
+ }
233
+ }) as number[] | number[][] | number[][][];
225
234
  }