@aibee/crc-bmap 0.0.88 → 0.0.90

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
@@ -424,9 +424,9 @@ function darkenColor(hexColor, factor = 0.85) {
424
424
  g = parseInt(numbers[1].trim());
425
425
  b = parseInt(numbers[2].trim());
426
426
  }
427
- r = Math.floor(r * factor);
428
- g = Math.floor(g * factor);
429
- b = Math.floor(b * factor);
427
+ r = Math.min(Math.floor(r * factor), 255);
428
+ g = Math.min(Math.floor(g * factor), 255);
429
+ b = Math.min(Math.floor(b * factor), 255);
430
430
  let darkHexColor = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
431
431
  return darkHexColor;
432
432
  }
@@ -540,7 +540,8 @@ var defaultOptions = {
540
540
  deltaHeight: 0,
541
541
  userData: {},
542
542
  gradualColor: [],
543
- renderType: "single"
543
+ renderType: "single",
544
+ colorFactor: 0.9
544
545
  };
545
546
  var Graphic = class extends Object3D {
546
547
  constructor(context, options) {
@@ -614,6 +615,10 @@ var Graphic = class extends Object3D {
614
615
  this.initMaterial();
615
616
  this.initMesh();
616
617
  });
618
+ this.addEventListener("change-gradualColor", () => {
619
+ this.initMaterial();
620
+ this.initMesh();
621
+ });
617
622
  }
618
623
  getCenter() {
619
624
  if (this.options.geometry.type === "point") {
@@ -698,7 +703,7 @@ var Graphic = class extends Object3D {
698
703
  return material;
699
704
  }
700
705
  const material1 = this.context.materialFactory.createShaderMaterial({
701
- gradualColor: [darkenColor(this.options.gradualColor[0], 0.95), darkenColor(this.options.gradualColor[1], 0.95)],
706
+ gradualColor: [darkenColor(this.options.gradualColor[0], this.options.colorFactor), darkenColor(this.options.gradualColor[1], this.options.colorFactor)],
702
707
  center: this.getCenter(),
703
708
  maxValue,
704
709
  opacity: this.options.fillOpacity,
@@ -964,6 +969,7 @@ var Overlay = class extends EventDispatcher {
964
969
  var defaultOptions3 = {
965
970
  texts: [{ text: "" }],
966
971
  level: 1,
972
+ icon_position: "bottom",
967
973
  collision_enable: true,
968
974
  opacity: 1,
969
975
  id: "",
@@ -1005,7 +1011,7 @@ var Poi = class extends EventDispatcher2 {
1005
1011
  this.addEventListener("change-icon", ({ value }) => {
1006
1012
  if (value) {
1007
1013
  if (!this.img) {
1008
- this.div.appendChild(this.initIcon());
1014
+ this.addIcon();
1009
1015
  this._changePosition();
1010
1016
  } else {
1011
1017
  this.img.setAttribute("src", value);
@@ -1019,11 +1025,7 @@ var Poi = class extends EventDispatcher2 {
1019
1025
  });
1020
1026
  this.addEventListener("change-texts", ({ value }) => {
1021
1027
  this.div.removeChild(this.textDiv);
1022
- if (this.div.firstChild) {
1023
- this.div.insertBefore(this.initText(), this.div.firstChild);
1024
- } else {
1025
- this.div.appendChild(this.initText());
1026
- }
1028
+ this.addText();
1027
1029
  this.resetSize();
1028
1030
  });
1029
1031
  this.addEventListener("change-opacity", ({ value }) => {
@@ -1081,9 +1083,10 @@ var Poi = class extends EventDispatcher2 {
1081
1083
  }
1082
1084
  initDiv() {
1083
1085
  const div = document.createElement("div");
1084
- div.appendChild(this.initText());
1086
+ this.div = div;
1087
+ this.addText();
1085
1088
  if (this.options.icon) {
1086
- div.appendChild(this.initIcon());
1089
+ this.addIcon();
1087
1090
  }
1088
1091
  div.style.fontSize = `12px`;
1089
1092
  div.style.textShadow = `#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0`;
@@ -1096,10 +1099,35 @@ var Poi = class extends EventDispatcher2 {
1096
1099
  this.overlay.div.style.pointerEvents = `none`;
1097
1100
  this.overlay.div.style.userSelect = `none`;
1098
1101
  this.overlay.div.appendChild(div);
1099
- this.div = div;
1100
1102
  this.resetSize();
1101
1103
  return div;
1102
1104
  }
1105
+ addIcon() {
1106
+ if (!this.img) {
1107
+ const icon = this.initIcon();
1108
+ if (this.options.icon_position === "top") {
1109
+ if (this.div.firstChild) {
1110
+ this.div.insertBefore(icon, this.div.firstChild);
1111
+ } else {
1112
+ this.div.appendChild(icon);
1113
+ }
1114
+ } else {
1115
+ this.div.appendChild(icon);
1116
+ }
1117
+ }
1118
+ }
1119
+ addText() {
1120
+ const text = this.initText();
1121
+ if (this.options.icon_position === "top") {
1122
+ this.div.appendChild(text);
1123
+ } else {
1124
+ if (this.div.firstChild) {
1125
+ this.div.insertBefore(text, this.div.firstChild);
1126
+ } else {
1127
+ this.div.appendChild(text);
1128
+ }
1129
+ }
1130
+ }
1103
1131
  getPosition() {
1104
1132
  return this.position;
1105
1133
  }