@antv/l7-component 2.9.32-alpha.2 → 2.9.32-alpha.4

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.
Files changed (114) hide show
  1. package/es/assets/iconfont/iconfont.js +53 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +191 -0
  6. package/es/control/baseControl/control.d.ts +107 -0
  7. package/es/control/baseControl/control.js +288 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +131 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +227 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +163 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +151 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +139 -0
  20. package/es/control/layerControl.d.ts +21 -0
  21. package/es/control/layerControl.js +172 -0
  22. package/es/control/logo.d.ts +13 -0
  23. package/es/control/logo.js +87 -0
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +135 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +104 -0
  28. package/es/control/scale.d.ts +34 -0
  29. package/es/control/scale.js +172 -0
  30. package/es/control/zoom.d.ts +34 -0
  31. package/es/control/zoom.js +146 -0
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +567 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +60 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +169 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +28 -0
  45. package/es/css/zoom.less +21 -0
  46. package/es/images/layers.png +0 -0
  47. package/es/images/layers.svg +1 -0
  48. package/es/images/logo.png +0 -0
  49. package/es/images/quanping.svg +12 -0
  50. package/es/index.d.ts +18 -0
  51. package/es/index.js +59 -0
  52. package/es/interface.d.ts +18 -0
  53. package/es/interface.js +1 -0
  54. package/es/marker-layer.d.ts +53 -0
  55. package/es/marker-layer.js +363 -0
  56. package/es/marker.d.ts +49 -0
  57. package/es/marker.js +434 -0
  58. package/es/popup/layerPopup.d.ts +78 -0
  59. package/es/popup/layerPopup.js +308 -0
  60. package/es/popup/popup.d.ts +147 -0
  61. package/es/popup/popup.js +636 -0
  62. package/es/utils/anchor.d.ts +22 -0
  63. package/es/utils/anchor.js +35 -0
  64. package/es/utils/icon.d.ts +1 -0
  65. package/es/utils/icon.js +9 -0
  66. package/es/utils/popper.d.ts +75 -0
  67. package/es/utils/popper.js +286 -0
  68. package/es/utils/screenfull.d.ts +2 -0
  69. package/es/utils/screenfull.js +157 -0
  70. package/lib/assets/iconfont/iconfont.js +39 -0
  71. package/lib/constants/index.js +90 -0
  72. package/lib/control/baseControl/buttonControl.js +118 -0
  73. package/lib/control/baseControl/control.js +172 -0
  74. package/lib/control/baseControl/index.js +22 -0
  75. package/lib/control/baseControl/popperControl.js +108 -0
  76. package/lib/control/baseControl/selectControl.js +153 -0
  77. package/lib/control/exportImage.js +83 -0
  78. package/lib/control/fullscreen.js +109 -0
  79. package/lib/control/geoLocate.js +78 -0
  80. package/lib/control/layerControl.js +136 -0
  81. package/lib/control/logo.js +74 -0
  82. package/lib/control/mapTheme.js +92 -0
  83. package/lib/control/mouseLocation.js +79 -0
  84. package/lib/control/scale.js +136 -0
  85. package/lib/control/zoom.js +119 -0
  86. package/lib/css/button.less +70 -0
  87. package/lib/css/control.less +71 -0
  88. package/lib/css/index.css +567 -0
  89. package/lib/css/index.less +12 -0
  90. package/lib/css/l7.less +60 -0
  91. package/lib/css/layerPopup.less +8 -0
  92. package/lib/css/logo.less +18 -0
  93. package/lib/css/mouseLocation.less +9 -0
  94. package/lib/css/popper.less +64 -0
  95. package/lib/css/popup.less +169 -0
  96. package/lib/css/scale.less +34 -0
  97. package/lib/css/select.less +86 -0
  98. package/lib/css/variables.less +28 -0
  99. package/lib/css/zoom.less +21 -0
  100. package/lib/images/layers.png +0 -0
  101. package/lib/images/layers.svg +1 -0
  102. package/lib/images/logo.png +0 -0
  103. package/lib/images/quanping.svg +12 -0
  104. package/lib/index.js +51 -0
  105. package/lib/interface.js +17 -0
  106. package/lib/marker-layer.js +263 -0
  107. package/lib/marker.js +307 -0
  108. package/lib/popup/layerPopup.js +200 -0
  109. package/lib/popup/popup.js +388 -0
  110. package/lib/utils/anchor.js +63 -0
  111. package/lib/utils/icon.js +37 -0
  112. package/lib/utils/popper.js +209 -0
  113. package/lib/utils/screenfull.js +160 -0
  114. package/package.json +5 -5
@@ -0,0 +1,200 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/popup/layerPopup.ts
23
+ var layerPopup_exports = {};
24
+ __export(layerPopup_exports, {
25
+ LayerPopup: () => LayerPopup,
26
+ default: () => LayerPopup
27
+ });
28
+ module.exports = __toCommonJS(layerPopup_exports);
29
+ var import_l7_utils = require("@antv/l7-utils");
30
+ var import_lodash = require("lodash");
31
+ var import_popup = __toESM(require("./popup"));
32
+ var LayerPopup = class extends import_popup.default {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.layerConfigMap = /* @__PURE__ */ new WeakMap();
36
+ }
37
+ addTo(scene) {
38
+ super.addTo(scene);
39
+ this.bindLayerEvent();
40
+ this.hide();
41
+ return this;
42
+ }
43
+ remove() {
44
+ super.remove();
45
+ this.unbindLayerEvent();
46
+ return this;
47
+ }
48
+ setOptions(option) {
49
+ this.unbindLayerEvent();
50
+ super.setOptions(option);
51
+ this.bindLayerEvent();
52
+ return this;
53
+ }
54
+ getDefault(option) {
55
+ const isClickTrigger = option.trigger === "click";
56
+ return {
57
+ ...super.getDefault(option),
58
+ trigger: "hover",
59
+ followCursor: !isClickTrigger,
60
+ lngLat: {
61
+ lng: 0,
62
+ lat: 0
63
+ },
64
+ offsets: [0, 10],
65
+ closeButton: false,
66
+ closeOnClick: false,
67
+ autoClose: false,
68
+ closeOnEsc: false
69
+ };
70
+ }
71
+ bindLayerEvent() {
72
+ const { config, trigger } = this.popupOption;
73
+ config.forEach((configItem) => {
74
+ const layer = this.getLayerByConfig(configItem);
75
+ if (!layer) {
76
+ return;
77
+ }
78
+ const layerInfo = {
79
+ ...configItem
80
+ };
81
+ if (trigger === "hover") {
82
+ const onMouseMove = this.onLayerMouseMove.bind(this, layer);
83
+ const onMouseOut = this.onLayerMouseOut.bind(this, layer);
84
+ layerInfo.onMouseMove = onMouseMove;
85
+ layerInfo.onMouseOut = onMouseOut;
86
+ layer == null ? void 0 : layer.on("mousemove", onMouseMove);
87
+ layer == null ? void 0 : layer.on("mouseout", onMouseOut);
88
+ } else {
89
+ const onClick = this.onLayerClick.bind(this, layer);
90
+ layerInfo.onClick = onClick;
91
+ layer == null ? void 0 : layer.on("click", onClick);
92
+ }
93
+ const source = layer.getSource();
94
+ const onSourceUpdate = this.onSourceUpdate.bind(this, layer);
95
+ source == null ? void 0 : source.on("update", onSourceUpdate);
96
+ layerInfo.onSourceUpdate = onSourceUpdate;
97
+ this.layerConfigMap.set(layer, layerInfo);
98
+ });
99
+ }
100
+ unbindLayerEvent() {
101
+ const { config } = this.popupOption;
102
+ config.forEach((configItem) => {
103
+ var _a;
104
+ const layer = this.getLayerByConfig(configItem);
105
+ const layerInfo = layer && this.layerConfigMap.get(layer);
106
+ if (!layerInfo) {
107
+ return;
108
+ }
109
+ const { onMouseMove, onMouseOut, onClick, onSourceUpdate } = layerInfo;
110
+ if (onMouseMove) {
111
+ layer.off("mousemove", onMouseMove);
112
+ }
113
+ if (onMouseOut) {
114
+ layer.off("mouseout", onMouseOut);
115
+ }
116
+ if (onClick) {
117
+ layer.off("click", onClick);
118
+ }
119
+ if (onSourceUpdate) {
120
+ (_a = layer == null ? void 0 : layer.getSource()) == null ? void 0 : _a.off("update", onSourceUpdate);
121
+ }
122
+ });
123
+ }
124
+ onLayerMouseMove(layer, e) {
125
+ if (!this.isSameFeature(layer, e.featureId)) {
126
+ const frag = this.getLayerInfoFrag(layer, e);
127
+ this.setDOMContent(frag);
128
+ this.displayFeatureInfo = {
129
+ layer,
130
+ featureId: e.featureId
131
+ };
132
+ }
133
+ if (!this.isShow) {
134
+ this.show();
135
+ }
136
+ }
137
+ onLayerMouseOut(layer, e) {
138
+ this.displayFeatureInfo = void 0;
139
+ if (this.isShow) {
140
+ this.hide();
141
+ }
142
+ }
143
+ onLayerClick(layer, e) {
144
+ if (this.isShow && this.isSameFeature(layer, e.featureId)) {
145
+ this.hide();
146
+ } else {
147
+ const frag = this.getLayerInfoFrag(layer, e);
148
+ this.setDOMContent(frag);
149
+ this.setLnglat(e.lngLat);
150
+ this.show();
151
+ this.displayFeatureInfo = {
152
+ layer,
153
+ featureId: e.featureId
154
+ };
155
+ }
156
+ }
157
+ onSourceUpdate(layer) {
158
+ var _a;
159
+ if (((_a = this.displayFeatureInfo) == null ? void 0 : _a.layer) === layer) {
160
+ this.hide();
161
+ this.displayFeatureInfo = void 0;
162
+ }
163
+ }
164
+ getLayerInfoFrag(layer, e) {
165
+ const layerInfo = this.layerConfigMap.get(layer);
166
+ const frag = document.createDocumentFragment();
167
+ if (layerInfo) {
168
+ let feature = e.feature;
169
+ if (feature.type === "Feature" && "properties" in feature && "geometry" in feature) {
170
+ feature = feature.properties;
171
+ }
172
+ const { fields } = layerInfo;
173
+ fields == null ? void 0 : fields.forEach((fieldConfig) => {
174
+ const { field, formatField, formatValue, getValue } = typeof fieldConfig === "string" ? { field: fieldConfig } : fieldConfig;
175
+ const row = import_l7_utils.DOM.create("div", "l7-layer-popup__row");
176
+ const value = getValue ? getValue(e.feature) : (0, import_lodash.get)(feature, field);
177
+ row.innerHTML = `${formatField ? formatField(field) : field}: ${formatValue ? formatValue(value) : value}`;
178
+ frag.appendChild(row);
179
+ });
180
+ }
181
+ return frag;
182
+ }
183
+ getLayerByConfig(config) {
184
+ const layer = config.layer;
185
+ if (layer instanceof Object) {
186
+ return layer;
187
+ }
188
+ if (typeof layer === "string") {
189
+ return this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
190
+ }
191
+ }
192
+ isSameFeature(layer, featureId) {
193
+ const displayFeatureInfo = this.displayFeatureInfo;
194
+ return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
195
+ }
196
+ };
197
+ // Annotate the CommonJS export names for ESM import in node:
198
+ 0 && (module.exports = {
199
+ LayerPopup
200
+ });
@@ -0,0 +1,388 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/popup/popup.ts
20
+ var popup_exports = {};
21
+ __export(popup_exports, {
22
+ Popup: () => Popup,
23
+ default: () => Popup
24
+ });
25
+ module.exports = __toCommonJS(popup_exports);
26
+ var import_l7_core = require("@antv/l7-core");
27
+ var import_l7_utils = require("@antv/l7-utils");
28
+ var import_eventemitter3 = require("eventemitter3");
29
+ var import_icon = require("../utils/icon");
30
+ var Popup = class extends import_eventemitter3.EventEmitter {
31
+ constructor(cfg) {
32
+ super();
33
+ this.isShow = true;
34
+ this.onMouseMove = (e) => {
35
+ const container = this.mapsService.getMapContainer();
36
+ const { left = 0, top = 0 } = (container == null ? void 0 : container.getBoundingClientRect()) ?? {};
37
+ this.setPopupPosition(e.clientX - left, e.clientY - top);
38
+ };
39
+ this.updateLngLatPosition = () => {
40
+ if (!this.mapsService || this.popupOption.followCursor) {
41
+ return;
42
+ }
43
+ const { lng, lat } = this.lngLat;
44
+ const { x, y } = this.mapsService.lngLatToContainer([lng, lat]);
45
+ this.setPopupPosition(x, y);
46
+ };
47
+ this.onKeyDown = (e) => {
48
+ if (e.keyCode === 27) {
49
+ this.remove();
50
+ }
51
+ };
52
+ this.onCloseButtonClick = (e) => {
53
+ if (e.stopPropagation) {
54
+ e.stopPropagation();
55
+ }
56
+ this.remove();
57
+ };
58
+ this.update = () => {
59
+ const hasPosition = !!this.lngLat;
60
+ const {
61
+ className,
62
+ style,
63
+ maxWidth,
64
+ anchor,
65
+ stopPropagation
66
+ } = this.popupOption;
67
+ if (!this.mapsService || !hasPosition || !this.content) {
68
+ return;
69
+ }
70
+ const popupContainer = this.mapsService.getMarkerContainer();
71
+ if (!this.container && popupContainer) {
72
+ this.container = import_l7_utils.DOM.create("div", `l7-popup ${className ?? ""} ${!this.isShow ? "l7-popup-hide" : ""}`, popupContainer);
73
+ if (style) {
74
+ this.container.setAttribute("style", style);
75
+ }
76
+ this.tip = import_l7_utils.DOM.create("div", "l7-popup-tip", this.container);
77
+ this.container.appendChild(this.content);
78
+ if (stopPropagation) {
79
+ ["mousemove", "mousedown", "mouseup", "click", "dblclick"].forEach((type) => {
80
+ this.container.addEventListener(type, (e) => {
81
+ e.stopPropagation();
82
+ });
83
+ });
84
+ }
85
+ this.container.style.whiteSpace = "nowrap";
86
+ }
87
+ if (maxWidth && this.container.style.maxWidth !== maxWidth) {
88
+ this.container.style.maxWidth = maxWidth;
89
+ }
90
+ this.updateLngLatPosition();
91
+ import_l7_utils.DOM.setTransform(this.container, `${import_l7_utils.anchorTranslate[anchor]}`);
92
+ (0, import_l7_utils.applyAnchorClass)(this.container, anchor, "popup");
93
+ };
94
+ this.popupOption = {
95
+ ...this.getDefault(cfg ?? {}),
96
+ ...cfg
97
+ };
98
+ const { lngLat } = this.popupOption;
99
+ if (lngLat) {
100
+ this.lngLat = lngLat;
101
+ }
102
+ }
103
+ get lngLat() {
104
+ return this.popupOption.lngLat ?? {
105
+ lng: 0,
106
+ lat: 0
107
+ };
108
+ }
109
+ set lngLat(newLngLat) {
110
+ this.popupOption.lngLat = newLngLat;
111
+ }
112
+ getIsShow() {
113
+ return this.isShow;
114
+ }
115
+ addTo(scene) {
116
+ this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
117
+ this.sceneService = scene.get(import_l7_core.TYPES.ISceneService);
118
+ this.layerService = scene.get(import_l7_core.TYPES.ILayerService);
119
+ this.mapsService.on("camerachange", this.update);
120
+ this.mapsService.on("viewchange", this.update);
121
+ this.scene = scene;
122
+ this.update();
123
+ this.updateCloseOnClick();
124
+ this.updateCloseOnEsc();
125
+ this.updateFollowCursor();
126
+ const { html, text } = this.popupOption;
127
+ if (html) {
128
+ this.setHTML(html);
129
+ } else if (text) {
130
+ this.setText(text);
131
+ }
132
+ this.emit("open");
133
+ return this;
134
+ }
135
+ remove() {
136
+ if (!this.isOpen()) {
137
+ return;
138
+ }
139
+ if (this.content) {
140
+ import_l7_utils.DOM.remove(this.content);
141
+ }
142
+ if (this.container) {
143
+ import_l7_utils.DOM.remove(this.container);
144
+ delete this.container;
145
+ }
146
+ if (this.mapsService) {
147
+ this.mapsService.off("camerachange", this.update);
148
+ this.mapsService.off("viewchange", this.update);
149
+ this.updateCloseOnClick(true);
150
+ this.updateCloseOnEsc(true);
151
+ this.updateFollowCursor(true);
152
+ delete this.mapsService;
153
+ }
154
+ this.emit("close");
155
+ return this;
156
+ }
157
+ getOptions() {
158
+ return this.popupOption;
159
+ }
160
+ setOptions(option) {
161
+ this.popupOption = {
162
+ ...this.popupOption,
163
+ ...option
164
+ };
165
+ if (this.checkUpdateOption(option, [
166
+ "closeButton",
167
+ "closeButtonOffsets",
168
+ "maxWidth",
169
+ "anchor",
170
+ "stopPropagation",
171
+ "className",
172
+ "style",
173
+ "lngLat",
174
+ "offsets",
175
+ "title"
176
+ ])) {
177
+ if (this.container) {
178
+ import_l7_utils.DOM.remove(this.container);
179
+ this.container = void 0;
180
+ }
181
+ if (this.popupOption.html) {
182
+ this.setHTML(this.popupOption.html);
183
+ } else if (this.popupOption.text) {
184
+ this.setText(this.popupOption.text);
185
+ }
186
+ }
187
+ if (this.checkUpdateOption(option, ["closeOnEsc"])) {
188
+ this.updateCloseOnEsc();
189
+ }
190
+ if (this.checkUpdateOption(option, ["closeOnClick"])) {
191
+ this.updateCloseOnClick();
192
+ }
193
+ if (this.checkUpdateOption(option, ["followCursor"])) {
194
+ this.updateFollowCursor();
195
+ }
196
+ if (this.checkUpdateOption(option, ["html"]) && option.html) {
197
+ this.setHTML(option.html);
198
+ } else if (this.checkUpdateOption(option, ["text"]) && option.text) {
199
+ this.setText(option.text);
200
+ }
201
+ if (this.checkUpdateOption(option, ["lngLat"]) && option.lngLat) {
202
+ this.setLnglat(option.lngLat);
203
+ }
204
+ return this;
205
+ }
206
+ open() {
207
+ this.addTo(this.scene);
208
+ return this;
209
+ }
210
+ close() {
211
+ this.remove();
212
+ return this;
213
+ }
214
+ show() {
215
+ if (this.isShow) {
216
+ return;
217
+ }
218
+ if (this.container) {
219
+ import_l7_utils.DOM.removeClass(this.container, "l7-popup-hide");
220
+ }
221
+ this.isShow = true;
222
+ this.emit("show");
223
+ return this;
224
+ }
225
+ hide() {
226
+ if (!this.isShow) {
227
+ return;
228
+ }
229
+ if (this.container) {
230
+ import_l7_utils.DOM.addClass(this.container, "l7-popup-hide");
231
+ }
232
+ this.isShow = false;
233
+ this.emit("hide");
234
+ return this;
235
+ }
236
+ setHTML(html) {
237
+ this.popupOption.html = html;
238
+ return this.setDOMContent(this.getPopupHTMLFragment(html));
239
+ }
240
+ setText(text) {
241
+ this.popupOption.text = text;
242
+ return this.setDOMContent(window.document.createTextNode(text));
243
+ }
244
+ panToPopup() {
245
+ const { lng, lat } = this.lngLat;
246
+ if (this.popupOption.autoPan) {
247
+ this.mapsService.panTo([lng, lat]);
248
+ }
249
+ return this;
250
+ }
251
+ setLngLat(lngLat) {
252
+ return this.setLnglat(lngLat);
253
+ }
254
+ setLnglat(lngLat) {
255
+ this.lngLat = lngLat;
256
+ if (Array.isArray(lngLat)) {
257
+ this.lngLat = {
258
+ lng: lngLat[0],
259
+ lat: lngLat[1]
260
+ };
261
+ }
262
+ if (this.mapsService) {
263
+ this.mapsService.off("camerachange", this.update);
264
+ this.mapsService.off("viewchange", this.update);
265
+ this.mapsService.on("camerachange", this.update);
266
+ this.mapsService.on("viewchange", this.update);
267
+ }
268
+ this.update();
269
+ if (this.popupOption.autoPan) {
270
+ setTimeout(() => {
271
+ this.panToPopup();
272
+ }, 0);
273
+ }
274
+ return this;
275
+ }
276
+ getLnglat() {
277
+ return this.lngLat;
278
+ }
279
+ setMaxWidth(maxWidth) {
280
+ this.popupOption.maxWidth = maxWidth;
281
+ this.update();
282
+ return this;
283
+ }
284
+ isOpen() {
285
+ return !!this.mapsService;
286
+ }
287
+ getDefault(option) {
288
+ return {
289
+ closeButton: true,
290
+ closeOnClick: true,
291
+ maxWidth: "240px",
292
+ offsets: [0, 0],
293
+ anchor: import_l7_utils.anchorType.BOTTOM,
294
+ stopPropagation: true,
295
+ autoPan: false,
296
+ autoClose: true,
297
+ closeOnEsc: false,
298
+ followCursor: false
299
+ };
300
+ }
301
+ setDOMContent(htmlNode) {
302
+ this.createContent();
303
+ this.contentPanel.appendChild(htmlNode);
304
+ this.update();
305
+ return this;
306
+ }
307
+ updateCloseOnClick(onlyClear) {
308
+ this.mapsService.off("click", this.onCloseButtonClick);
309
+ if (this.popupOption.closeOnClick && !onlyClear) {
310
+ this.mapsService.on("click", this.onCloseButtonClick);
311
+ }
312
+ }
313
+ updateCloseOnEsc(onlyClear) {
314
+ window.removeEventListener("keydown", this.onKeyDown);
315
+ if (this.popupOption.closeOnEsc && !onlyClear) {
316
+ window.addEventListener("keydown", this.onKeyDown);
317
+ }
318
+ }
319
+ updateFollowCursor(onlyClear) {
320
+ const container = this.mapsService.getContainer();
321
+ container.removeEventListener("mousemove", this.onMouseMove);
322
+ if (this.popupOption.followCursor && !onlyClear) {
323
+ container.addEventListener("mousemove", this.onMouseMove);
324
+ }
325
+ }
326
+ createContent() {
327
+ var _a;
328
+ if (this.content) {
329
+ import_l7_utils.DOM.remove(this.content);
330
+ }
331
+ this.content = import_l7_utils.DOM.create("div", "l7-popup-content", this.container);
332
+ if (this.popupOption.title) {
333
+ this.contentTitle = import_l7_utils.DOM.create("div", "l7-popup-content__title", this.content);
334
+ (_a = this.contentTitle) == null ? void 0 : _a.append(this.getPopupHTMLFragment(this.popupOption.title));
335
+ } else {
336
+ this.contentTitle = void 0;
337
+ }
338
+ if (this.popupOption.closeButton) {
339
+ const closeButton = (0, import_icon.createL7Icon)("l7-icon-guanbi");
340
+ import_l7_utils.DOM.addClass(closeButton, "l7-popup-close-button");
341
+ this.content.appendChild(closeButton);
342
+ if (this.popupOption.closeButtonOffsets) {
343
+ closeButton.style.right = this.popupOption.closeButtonOffsets[0] + "px";
344
+ closeButton.style.top = this.popupOption.closeButtonOffsets[1] + "px";
345
+ }
346
+ closeButton.setAttribute("aria-label", "Close popup");
347
+ closeButton.addEventListener("click", this.onCloseButtonClick);
348
+ this.closeButton = closeButton;
349
+ } else {
350
+ this.closeButton = void 0;
351
+ }
352
+ this.contentPanel = import_l7_utils.DOM.create("div", "l7-popup-content__panel", this.content);
353
+ }
354
+ setPopupPosition(left, top) {
355
+ if (this.container) {
356
+ const { offsets } = this.popupOption;
357
+ this.container.style.left = left + offsets[0] + "px";
358
+ this.container.style.top = top - offsets[1] + "px";
359
+ }
360
+ }
361
+ checkUpdateOption(option, keys) {
362
+ return keys.some((key) => key in option);
363
+ }
364
+ getPopupHTMLFragment(html) {
365
+ const frag = window.document.createDocumentFragment();
366
+ const temp = window.document.createElement("body");
367
+ let child;
368
+ if (typeof html === "string") {
369
+ temp.innerHTML = html;
370
+ } else if (Array.isArray(html)) {
371
+ temp.append(...html);
372
+ } else if (html instanceof HTMLElement) {
373
+ temp.append(html);
374
+ }
375
+ while (true) {
376
+ child = temp.firstChild;
377
+ if (!child) {
378
+ break;
379
+ }
380
+ frag.appendChild(child);
381
+ }
382
+ return frag;
383
+ }
384
+ };
385
+ // Annotate the CommonJS export names for ESM import in node:
386
+ 0 && (module.exports = {
387
+ Popup
388
+ });
@@ -0,0 +1,63 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/anchor.ts
20
+ var anchor_exports = {};
21
+ __export(anchor_exports, {
22
+ anchorTranslate: () => anchorTranslate,
23
+ anchorType: () => anchorType,
24
+ applyAnchorClass: () => applyAnchorClass
25
+ });
26
+ module.exports = __toCommonJS(anchor_exports);
27
+ var anchorType = /* @__PURE__ */ ((anchorType2) => {
28
+ anchorType2["CENTER"] = "center";
29
+ anchorType2["TOP"] = "top";
30
+ anchorType2["TOP-LEFT"] = "top-left";
31
+ anchorType2["TOP-RIGHT"] = "top-right";
32
+ anchorType2["BOTTOM"] = "bottom";
33
+ anchorType2["BOTTOM-LEFT"] = "bottom-left";
34
+ anchorType2["LEFT"] = "left";
35
+ anchorType2["RIGHT"] = "right";
36
+ return anchorType2;
37
+ })(anchorType || {});
38
+ var anchorTranslate = {
39
+ center: "translate(-50%,-50%)",
40
+ top: "translate(-50%,0)",
41
+ "top-left": "translate(0,0)",
42
+ "top-right": "translate(-100%,0)",
43
+ bottom: "translate(-50%,-100%)",
44
+ "bottom-left": "translate(0,-100%)",
45
+ "bottom-right": "translate(-100%,-100%)",
46
+ left: "translate(0,-50%)",
47
+ right: "translate(-100%,-50%)"
48
+ };
49
+ function applyAnchorClass(element, anchor, prefix) {
50
+ const classList = element.classList;
51
+ for (const key in anchorTranslate) {
52
+ if (anchorTranslate.hasOwnProperty(key)) {
53
+ classList.remove(`l7-${prefix}-anchor-${key}`);
54
+ }
55
+ }
56
+ classList.add(`l7-${prefix}-anchor-${anchor}`);
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ anchorTranslate,
61
+ anchorType,
62
+ applyAnchorClass
63
+ });
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/icon.ts
20
+ var icon_exports = {};
21
+ __export(icon_exports, {
22
+ createL7Icon: () => createL7Icon
23
+ });
24
+ module.exports = __toCommonJS(icon_exports);
25
+ var createL7Icon = (className) => {
26
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
27
+ svg.classList.add("l7-iconfont");
28
+ svg.setAttribute("aria-hidden", "true");
29
+ const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
30
+ use.setAttributeNS("http://www.w3.org/1999/xlink", "href", `#${className}`);
31
+ svg.appendChild(use);
32
+ return svg;
33
+ };
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ createL7Icon
37
+ });