@aibee/crc-bmap 0.0.60 → 0.0.61

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/lib/bmap.esm.js CHANGED
@@ -302,8 +302,11 @@ function proxyOptions(target, master) {
302
302
  return Reflect.get(target2, p, receiver);
303
303
  },
304
304
  set: (target2, p, newValue, receiver) => {
305
+ const oldValue = Reflect.get(target2, p, receiver);
305
306
  const res = Reflect.set(target2, p, newValue, receiver);
306
- master.dispatchEvent({ type: `change-${p}`, value: newValue });
307
+ if (oldValue !== newValue) {
308
+ master.dispatchEvent({ type: `change-${p}`, value: newValue });
309
+ }
307
310
  return res;
308
311
  }
309
312
  });
@@ -551,7 +554,7 @@ var Graphic = class extends Object3D {
551
554
  this.geometry = this.initGeometry();
552
555
  this.initMaterial();
553
556
  this.initMesh();
554
- this.mesh.position.z = this.options.airHeight;
557
+ this.mesh.position.z = this.options.airHeight + this.options.deltaHeight;
555
558
  if (this.options.stroke) {
556
559
  this.initLineMaterial();
557
560
  this.initLineGeometry();
@@ -566,7 +569,7 @@ var Graphic = class extends Object3D {
566
569
  const geometry = new ExtrudeGeometry(shape, {
567
570
  steps: 1,
568
571
  bevelEnabled: false,
569
- depth: this.options.height + this.options.deltaHeight,
572
+ depth: this.options.height,
570
573
  curveSegments: 4
571
574
  });
572
575
  return geometry;
@@ -805,7 +808,7 @@ var Overlay = class extends EventDispatcher {
805
808
  dispose() {
806
809
  this.unRegistryEvent();
807
810
  this.unBindElement();
808
- this.context.container.removeChild(this.div);
811
+ this.div && this.context.container.removeChild(this.div);
809
812
  this.div = null;
810
813
  }
811
814
  };
@@ -817,7 +820,10 @@ var defaultOptions3 = {
817
820
  collision_enable: true,
818
821
  opacity: 1,
819
822
  id: "",
820
- position: { x: 0, y: 0, z: 0 }
823
+ position: { x: 0, y: 0, z: 0 },
824
+ icon_opacity: 1,
825
+ icon_border: { color: "#586EE0", width: 0 },
826
+ background: ""
821
827
  };
822
828
  var Poi = class extends EventDispatcher2 {
823
829
  constructor(context, options) {
@@ -869,6 +875,20 @@ var Poi = class extends EventDispatcher2 {
869
875
  this.resetSize();
870
876
  }
871
877
  });
878
+ this.addEventListener("change-icon_opacity", ({ value }) => {
879
+ if (this.img) {
880
+ this.img.style.opacity = `${value}`;
881
+ }
882
+ });
883
+ this.addEventListener("change-icon_border", ({ value }) => {
884
+ if (this.img) {
885
+ this.img.style.border = `${value.width}px solid ${value.color}`;
886
+ this.resetSize();
887
+ }
888
+ });
889
+ this.addEventListener("change-background", ({ value }) => {
890
+ this.div.style.background = value;
891
+ });
872
892
  }
873
893
  get withinDisplayRange() {
874
894
  return this.overlay.withinDisplayRange;
@@ -904,6 +924,7 @@ var Poi = class extends EventDispatcher2 {
904
924
  div.style.flexDirection = `column`;
905
925
  div.style.justifyContent = `center`;
906
926
  div.style.alignItems = `center`;
927
+ div.style.padding = "4px";
907
928
  this.overlay.setOpacity(this.options.opacity);
908
929
  this.overlay.div.style.pointerEvents = `none`;
909
930
  this.overlay.div.style.userSelect = `none`;
@@ -945,6 +966,11 @@ var Poi = class extends EventDispatcher2 {
945
966
  img.setAttribute("src", this.options.icon);
946
967
  img.style.width = `${((_a = this.options.icon_size) == null ? void 0 : _a[0]) || 32}px`;
947
968
  img.style.height = `${((_b = this.options.icon_size) == null ? void 0 : _b[1]) || 32}px`;
969
+ img.style.opacity = `${this.options.icon_opacity}px`;
970
+ img.style.borderRadius = "50%";
971
+ if (this.options.icon_border.width) {
972
+ img.style.border = `${this.options.icon_border.width}px solid ${this.options.icon_border.color}`;
973
+ }
948
974
  img.onload = () => {
949
975
  this._changePosition();
950
976
  this.resetSize();
@@ -1019,7 +1045,6 @@ var GraphicLayer = class extends Layer {
1019
1045
  return box.getCenter(new Vector35());
1020
1046
  }
1021
1047
  createGraphic(options) {
1022
- options.deltaHeight = 1e-5 * this.graphicMap.size;
1023
1048
  const graphic = new Graphic(this.context, options);
1024
1049
  this.add(graphic);
1025
1050
  this.graphicMap.set(options.id, graphic);
@@ -1315,7 +1340,6 @@ var Floor = class extends Object3D7 {
1315
1340
  this.add(this.groundUpper);
1316
1341
  }
1317
1342
  createGround(options) {
1318
- options.deltaHeight = 1e-5 * this.grounds.size;
1319
1343
  const ground = new Graphic(this.context, options);
1320
1344
  this.addGrounds([ground]);
1321
1345
  }
@@ -1331,7 +1355,7 @@ var Floor = class extends Object3D7 {
1331
1355
  }
1332
1356
  changeGroundMaxHeight() {
1333
1357
  const grounds = Array.from(this.grounds);
1334
- this.groundMaxHeight = this.grounds.size > 0 ? Math.max(...grounds.map((ground) => ground.options.height + ground.options.airHeight)) : 0;
1358
+ this.groundMaxHeight = this.grounds.size > 0 ? Math.max(...grounds.map((ground) => ground.options.height + ground.options.airHeight + ground.options.deltaHeight)) : 0;
1335
1359
  this.graphicLayer.position.z = this.groundMaxHeight;
1336
1360
  }
1337
1361
  get hasElement() {
@@ -2581,6 +2605,7 @@ function getConfig(config) {
2581
2605
  }
2582
2606
 
2583
2607
  // src/bmap.ts
2608
+ import { debounce as debounce2 } from "lodash";
2584
2609
  var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
2585
2610
  MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
2586
2611
  MapTypePolar2[MapTypePolar2["D3"] = 0.9] = "D3";
@@ -2725,7 +2750,9 @@ var BMap = class extends EventDispatcher7 {
2725
2750
  });
2726
2751
  }
2727
2752
  const { ground, markGraphic, graphic } = this.config;
2728
- for (const item of data) {
2753
+ for (let i = 0; i < data.length; i++) {
2754
+ const item = data[i];
2755
+ item.info.deltaHeight = 1e-5 * (i + 1);
2729
2756
  if (item.info.group === "ground") {
2730
2757
  item.info.fillColor = ground.color;
2731
2758
  item.info.fillOpacity = ground.opacity;
@@ -2907,7 +2934,7 @@ var BMap = class extends EventDispatcher7 {
2907
2934
  window.addEventListener("keydown", this.onKeydown);
2908
2935
  window.addEventListener("keyup", this.onKeyUp);
2909
2936
  if (this.config.resizeObserver) {
2910
- const observe = new ResizeObserver(this.resize);
2937
+ const observe = new ResizeObserver(debounce2(this.resize, 5));
2911
2938
  observe.observe(this.container);
2912
2939
  this.observe = observe;
2913
2940
  }