jky-component-lib 0.0.88 → 0.0.94

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 (47) hide show
  1. package/dist/es/add-input/AddInput.vue.js +3 -3
  2. package/dist/es/amap/AMap.vue.d.ts +61 -0
  3. package/dist/es/amap/AMap.vue.js +292 -0
  4. package/dist/es/amap/AMap.vue3.js +5 -0
  5. package/dist/es/amap/AMarker.vue.d.ts +38 -0
  6. package/dist/es/amap/AMarker.vue.js +253 -0
  7. package/dist/es/amap/AMarker.vue3.js +5 -0
  8. package/dist/es/amap/index.d.ts +7 -0
  9. package/dist/es/amap/index.js +13 -0
  10. package/dist/es/amap/style.css +7 -0
  11. package/dist/es/amap/style2.css +14 -0
  12. package/dist/es/components.d.ts +1 -0
  13. package/dist/es/components.js +6 -1
  14. package/dist/es/form/FormItem.vue.js +6 -6
  15. package/dist/es/index.js +6 -0
  16. package/dist/es/package.json.js +1 -1
  17. package/dist/es/page-header/PopoverMenu.vue.d.ts +1 -1
  18. package/dist/es/page-table/PageTable.vue.d.ts +4 -4
  19. package/dist/es/page-table/Toolbar.vue.js +2 -2
  20. package/dist/es/rich-editor/RichEditor.vue.d.ts +1 -1
  21. package/dist/es/style.css +34 -0
  22. package/dist/es/styles.css +1 -1
  23. package/dist/lib/add-input/AddInput.vue.js +10 -10
  24. package/dist/lib/amap/AMap.vue.d.ts +61 -0
  25. package/dist/lib/amap/AMap.vue.js +292 -0
  26. package/dist/lib/amap/AMap.vue3.js +5 -0
  27. package/dist/lib/amap/AMarker.vue.d.ts +38 -0
  28. package/dist/lib/amap/AMarker.vue.js +253 -0
  29. package/dist/lib/amap/AMarker.vue3.js +5 -0
  30. package/dist/lib/amap/index.d.ts +7 -0
  31. package/dist/lib/amap/index.js +13 -0
  32. package/dist/lib/amap/style.css +7 -0
  33. package/dist/lib/amap/style2.css +14 -0
  34. package/dist/lib/components.d.ts +1 -0
  35. package/dist/lib/components.js +43 -39
  36. package/dist/lib/form/FormItem.vue.js +6 -6
  37. package/dist/lib/index.js +32 -26
  38. package/dist/lib/package.json.js +1 -1
  39. package/dist/lib/page-header/PopoverMenu.vue.d.ts +1 -1
  40. package/dist/lib/page-table/PageTable.vue.d.ts +4 -4
  41. package/dist/lib/page-table/Toolbar.vue.js +18 -18
  42. package/dist/lib/rich-editor/RichEditor.vue.d.ts +1 -1
  43. package/dist/lib/style.css +34 -0
  44. package/dist/lib/styles.css +1 -1
  45. package/package.json +11 -4
  46. package/dist/es/node_modules/@element-plus/icons-vue/dist/index.js +0 -116
  47. package/dist/lib/node_modules/@element-plus/icons-vue/dist/index.js +0 -116
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { defineComponent, useModel, ref, watch, openBlock, createElementBlock, Fragment, renderList, createVNode, unref, createElementVNode, createBlock, withCtx, createTextVNode, toDisplayString, mergeModels } from "vue";
21
- import { Plus as plus_default, Delete as delete_default } from "../node_modules/@element-plus/icons-vue/dist/index.js";
21
+ import { Plus, Delete } from "@element-plus/icons-vue";
22
22
  import { ElInput, ElButton } from "element-plus";
23
23
  const _hoisted_1 = { class: "jky-add-input" };
24
24
  const _hoisted_2 = { class: "jky-add-input__actions" };
@@ -120,7 +120,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
120
120
  key: 0,
121
121
  type: "primary",
122
122
  disabled: __props.disabled || __props.readonly,
123
- icon: unref(plus_default),
123
+ icon: unref(Plus),
124
124
  onClick: handleAdd
125
125
  }, {
126
126
  default: withCtx(() => [
@@ -131,7 +131,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
131
131
  key: 1,
132
132
  type: "danger",
133
133
  disabled: __props.disabled || __props.readonly,
134
- icon: unref(delete_default),
134
+ icon: unref(Delete),
135
135
  onClick: ($event) => handleDelete(index)
136
136
  }, {
137
137
  default: withCtx(() => [
@@ -0,0 +1,61 @@
1
+ import { AMapProps } from './types';
2
+ declare function __VLS_template(): {
3
+ attrs: Partial<{}>;
4
+ slots: {
5
+ default?(_: {}): any;
6
+ };
7
+ refs: {
8
+ mapRef: HTMLDivElement;
9
+ };
10
+ rootEl: HTMLDivElement;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: import('vue').DefineComponent<AMapProps, {
14
+ getMapInstance: () => any;
15
+ addMarker: (options: any) => any;
16
+ removeMarker: (marker: any) => void;
17
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
18
+ click: (data: any) => any;
19
+ moveend: (center: {
20
+ lng: number;
21
+ lat: number;
22
+ }) => any;
23
+ zoomend: (zoom: number) => any;
24
+ ready: (map: any) => any;
25
+ }, string, import('vue').PublicProps, Readonly<AMapProps> & Readonly<{
26
+ onClick?: ((data: any) => any) | undefined;
27
+ onMoveend?: ((center: {
28
+ lng: number;
29
+ lat: number;
30
+ }) => any) | undefined;
31
+ onZoomend?: ((zoom: number) => any) | undefined;
32
+ onReady?: ((map: any) => any) | undefined;
33
+ }>, {
34
+ width: string;
35
+ height: string;
36
+ token: string;
37
+ zoom: number;
38
+ viewMode: import('./types').MapViewMode;
39
+ showScale: boolean;
40
+ showHawkEye: boolean;
41
+ showToolbar: boolean;
42
+ showControlBar: boolean;
43
+ showGeolocation: boolean;
44
+ scalePosition: import('./types').ControlPosition;
45
+ hawkEyePosition: import('./types').ControlPosition;
46
+ toolbarPosition: import('./types').ControlPosition;
47
+ controlBarPosition: import('./types').ControlBarPosition;
48
+ geolocationPosition: import('./types').ControlPosition;
49
+ enableHighAccuracy: boolean;
50
+ timeout: number;
51
+ zoomToAccuracy: boolean;
52
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
53
+ mapRef: HTMLDivElement;
54
+ }, HTMLDivElement>;
55
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
56
+ export default _default;
57
+ type __VLS_WithTemplateSlots<T, S> = T & {
58
+ new (): {
59
+ $slots: S;
60
+ };
61
+ };
@@ -0,0 +1,292 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import { defineComponent, ref, computed, watch, provide, onMounted, openBlock, createElementBlock, createElementVNode, normalizeStyle, renderSlot, createCommentVNode, nextTick, unref } from "vue";
41
+ import { ElMessage } from "element-plus";
42
+ const _hoisted_1 = { class: "jky-amap-wrapper" };
43
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
44
+ name: "JkyAMap"
45
+ }), {
46
+ __name: "AMap",
47
+ props: {
48
+ token: { default: "75f62fbef756459563f042e5a2a1fd7c" },
49
+ zoom: { default: 11 },
50
+ center: {},
51
+ viewMode: { default: "3D" },
52
+ width: { default: "100%" },
53
+ height: { default: "100%" },
54
+ showScale: { type: Boolean, default: false },
55
+ showHawkEye: { type: Boolean, default: false },
56
+ showToolbar: { type: Boolean, default: false },
57
+ showControlBar: { type: Boolean, default: false },
58
+ showGeolocation: { type: Boolean, default: false },
59
+ scalePosition: { default: "LB" },
60
+ hawkEyePosition: { default: "RB" },
61
+ toolbarPosition: { default: "LT" },
62
+ controlBarPosition: { default: () => ({
63
+ top: "10px",
64
+ left: "50%",
65
+ transform: "translateX(-50%)"
66
+ }) },
67
+ geolocationPosition: { default: "RB" },
68
+ enableHighAccuracy: { type: Boolean, default: true },
69
+ timeout: { default: 1e4 },
70
+ zoomToAccuracy: { type: Boolean, default: true }
71
+ },
72
+ emits: ["moveend", "zoomend", "click", "ready"],
73
+ setup(__props, { expose: __expose, emit: __emit }) {
74
+ const props = __props;
75
+ const emit = __emit;
76
+ const mapRef = ref(null);
77
+ const mapInstance = ref(null);
78
+ const isMapLoaded = ref(false);
79
+ const controls = ref({});
80
+ const getMapUrl = computed(() => {
81
+ const plugins = [];
82
+ if (props.showScale)
83
+ plugins.push("AMap.Scale");
84
+ if (props.showHawkEye)
85
+ plugins.push("AMap.HawkEye");
86
+ if (props.showToolbar)
87
+ plugins.push("AMap.ToolBar");
88
+ if (props.showControlBar)
89
+ plugins.push("AMap.ControlBar");
90
+ if (props.showGeolocation)
91
+ plugins.push("AMap.Geolocation");
92
+ const pluginStr = plugins.length > 0 ? `&plugin=${plugins.join(",")}` : "";
93
+ return `https://webapi.amap.com/maps?v=2.0&key=${props.token}${pluginStr}`;
94
+ });
95
+ function loadMapScript() {
96
+ return new Promise((resolve, reject) => {
97
+ if (window.AMap) {
98
+ resolve();
99
+ return;
100
+ }
101
+ const script = document.createElement("script");
102
+ script.type = "text/javascript";
103
+ script.src = getMapUrl.value;
104
+ script.onload = () => resolve();
105
+ script.onerror = () => reject(new Error("Failed to load AMap script"));
106
+ document.head.appendChild(script);
107
+ });
108
+ }
109
+ function initMap() {
110
+ return __async(this, null, function* () {
111
+ if (!props.token) {
112
+ console.error("AMap token is required");
113
+ return;
114
+ }
115
+ try {
116
+ yield loadMapScript();
117
+ yield nextTick();
118
+ const wrapEl = unref(mapRef);
119
+ if (!wrapEl)
120
+ return;
121
+ const AMap = window.AMap;
122
+ const map = new AMap.Map(wrapEl, {
123
+ zoom: props.zoom,
124
+ center: props.center,
125
+ viewMode: props.viewMode
126
+ });
127
+ mapInstance.value = map;
128
+ isMapLoaded.value = true;
129
+ addControls(map, AMap);
130
+ map.on("moveend", () => {
131
+ const center = map.getCenter();
132
+ emit("moveend", { lng: center.lng, lat: center.lat });
133
+ });
134
+ map.on("zoomend", () => {
135
+ const zoom = map.getZoom();
136
+ emit("zoomend", zoom);
137
+ });
138
+ map.on("click", (e) => {
139
+ emit("click", e);
140
+ });
141
+ emit("ready", map);
142
+ } catch (error) {
143
+ console.error("Failed to initialize AMap:", error);
144
+ }
145
+ });
146
+ }
147
+ function addControls(map, AMap) {
148
+ if (props.showScale) {
149
+ const scaleControl = new AMap.Scale({
150
+ position: props.scalePosition
151
+ });
152
+ map.addControl(scaleControl);
153
+ controls.value.scale = scaleControl;
154
+ }
155
+ if (props.showHawkEye) {
156
+ const hawkEyeControl = new AMap.HawkEye({
157
+ position: props.hawkEyePosition
158
+ });
159
+ map.addControl(hawkEyeControl);
160
+ controls.value.hawkEye = hawkEyeControl;
161
+ }
162
+ if (props.showToolbar) {
163
+ const toolbarControl = new AMap.ToolBar({
164
+ position: props.toolbarPosition
165
+ });
166
+ map.addControl(toolbarControl);
167
+ controls.value.toolbar = toolbarControl;
168
+ }
169
+ if (props.showControlBar) {
170
+ const controlBar = new AMap.ControlBar({
171
+ position: props.controlBarPosition
172
+ });
173
+ map.addControl(controlBar);
174
+ controls.value.controlBar = controlBar;
175
+ }
176
+ if (props.showGeolocation) {
177
+ AMap.plugin("AMap.Geolocation", () => {
178
+ const geolocation = new AMap.Geolocation({
179
+ enableHighAccuracy: props.enableHighAccuracy,
180
+ timeout: props.timeout,
181
+ position: props.geolocationPosition,
182
+ offset: [10, 20],
183
+ zoomToAccuracy: props.zoomToAccuracy
184
+ });
185
+ map.addControl(geolocation);
186
+ controls.value.geolocation = geolocation;
187
+ });
188
+ }
189
+ }
190
+ function removeControls() {
191
+ if (!mapInstance.value)
192
+ return;
193
+ const map = mapInstance.value;
194
+ Object.values(controls.value).forEach((control) => {
195
+ if (control) {
196
+ map.removeControl(control);
197
+ }
198
+ });
199
+ controls.value = {};
200
+ }
201
+ function updateControls() {
202
+ if (!mapInstance.value || !isMapLoaded.value)
203
+ return;
204
+ removeControls();
205
+ const AMap = window.AMap;
206
+ addControls(mapInstance.value, AMap);
207
+ }
208
+ watch(
209
+ () => props.token,
210
+ () => {
211
+ if (isMapLoaded.value && props.token) {
212
+ initMap();
213
+ }
214
+ }
215
+ );
216
+ watch(
217
+ [
218
+ () => props.showScale,
219
+ () => props.showHawkEye,
220
+ () => props.showToolbar,
221
+ () => props.showControlBar,
222
+ () => props.showGeolocation
223
+ ],
224
+ () => {
225
+ if (isMapLoaded.value && mapInstance.value) {
226
+ updateControls();
227
+ }
228
+ }
229
+ );
230
+ watch(
231
+ () => props.viewMode,
232
+ (newMode) => {
233
+ if (isMapLoaded.value && mapInstance.value) {
234
+ mapInstance.value.setMapStyle(newMode === "3D" ? "amap://styles/dark" : "amap://styles/normal");
235
+ ElMessage.info(`切换到${newMode}模式`);
236
+ }
237
+ }
238
+ );
239
+ const context = {
240
+ get map() {
241
+ return mapInstance.value;
242
+ },
243
+ isMapLoaded: computed(() => {
244
+ return isMapLoaded.value;
245
+ }),
246
+ addMarker: (options) => {
247
+ if (mapInstance.value) {
248
+ return new window.AMap.Marker(options);
249
+ }
250
+ },
251
+ removeMarker: (marker) => {
252
+ if (mapInstance.value && marker) {
253
+ mapInstance.value.remove(marker);
254
+ }
255
+ },
256
+ getMapInstance: () => mapInstance.value
257
+ };
258
+ provide("amapContext", context);
259
+ __expose({
260
+ getMapInstance: () => mapInstance.value,
261
+ addMarker: (options) => {
262
+ if (mapInstance.value) {
263
+ return new window.AMap.Marker(options);
264
+ }
265
+ },
266
+ removeMarker: (marker) => {
267
+ if (mapInstance.value && marker) {
268
+ mapInstance.value.remove(marker);
269
+ }
270
+ }
271
+ });
272
+ onMounted(() => {
273
+ if (props.token) {
274
+ initMap();
275
+ }
276
+ });
277
+ return (_ctx, _cache) => {
278
+ return openBlock(), createElementBlock("div", _hoisted_1, [
279
+ createElementVNode("div", {
280
+ ref_key: "mapRef",
281
+ ref: mapRef,
282
+ class: "jky-amap-container",
283
+ style: normalizeStyle({ width: __props.width, height: __props.height })
284
+ }, null, 4),
285
+ isMapLoaded.value && mapInstance.value ? renderSlot(_ctx.$slots, "default", { key: 0 }) : createCommentVNode("", true)
286
+ ]);
287
+ };
288
+ }
289
+ }));
290
+ export {
291
+ _sfc_main as default
292
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./AMap.vue.js";
2
+ /* empty css */
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,38 @@
1
+ import { AMapMarkerProps, MarkerData } from './types';
2
+ declare function removeMarkers(): void;
3
+ declare function __VLS_template(): {
4
+ attrs: Partial<{}>;
5
+ slots: {
6
+ default?(_: {}): any;
7
+ };
8
+ refs: {};
9
+ rootEl: any;
10
+ };
11
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
12
+ declare const __VLS_component: import('vue').DefineComponent<AMapMarkerProps, {
13
+ getMarkers: () => any[];
14
+ clearMarkers: typeof removeMarkers;
15
+ addMarker: (data: MarkerData) => any;
16
+ removeMarker: (marker: any) => void;
17
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
18
+ click: (marker: any, data: MarkerData) => any;
19
+ dragend: (marker: any, data: MarkerData) => any;
20
+ mouseout: (marker: any, data: MarkerData) => any;
21
+ mouseover: (marker: any, data: MarkerData) => any;
22
+ }, string, import('vue').PublicProps, Readonly<AMapMarkerProps> & Readonly<{
23
+ onClick?: ((marker: any, data: MarkerData) => any) | undefined;
24
+ onDragend?: ((marker: any, data: MarkerData) => any) | undefined;
25
+ onMouseout?: ((marker: any, data: MarkerData) => any) | undefined;
26
+ onMouseover?: ((marker: any, data: MarkerData) => any) | undefined;
27
+ }>, {
28
+ draggable: boolean;
29
+ visible: boolean;
30
+ updateMode: "incremental" | "full";
31
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
32
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
33
+ export default _default;
34
+ type __VLS_WithTemplateSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,253 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { defineComponent, ref, inject, onMounted, onUnmounted, watch, renderSlot, render, h } from "vue";
21
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
22
+ name: "JkyAMarker"
23
+ }), {
24
+ __name: "AMarker",
25
+ props: {
26
+ markers: {},
27
+ position: {},
28
+ title: {},
29
+ content: {},
30
+ draggable: { type: Boolean, default: false },
31
+ icon: {},
32
+ offset: {},
33
+ visible: { type: Boolean, default: true },
34
+ updateMode: { default: "full" }
35
+ },
36
+ emits: ["click", "dragend", "mouseover", "mouseout"],
37
+ setup(__props, { expose: __expose, emit: __emit }) {
38
+ const props = __props;
39
+ const emit = __emit;
40
+ const markers = ref([]);
41
+ const amapContext = inject("amapContext", null);
42
+ const mapInstance = (amapContext == null ? void 0 : amapContext.getMapInstance()) || null;
43
+ const contentCleanupFns = /* @__PURE__ */ new WeakMap();
44
+ function renderVueComponent(component, props2) {
45
+ const container = document.createElement("div");
46
+ const vnode = h(component, props2);
47
+ render(vnode, container);
48
+ return container.firstElementChild || container;
49
+ }
50
+ function createMarker(data) {
51
+ const AMap = window.AMap;
52
+ if (!AMap || !mapInstance) {
53
+ console.error("AMap map instance is required");
54
+ return null;
55
+ }
56
+ const markerOptions = {
57
+ position: data.position,
58
+ title: data.title,
59
+ draggable: data.draggable,
60
+ visible: data.visible !== false,
61
+ extData: data
62
+ };
63
+ if (data.content) {
64
+ if (data.content instanceof HTMLElement || data.content === "string") {
65
+ markerOptions.content = data.content;
66
+ } else if (typeof data.content === "object" && data.content !== null) {
67
+ const isVueComponent = data.content.render || data.content.template || data.content.setup;
68
+ if (isVueComponent) {
69
+ const contentElement = renderVueComponent(data.content);
70
+ markerOptions.content = contentElement;
71
+ contentCleanupFns.set(markerOptions, () => {
72
+ if (contentElement.parentElement) {
73
+ render(null, contentElement.parentElement);
74
+ }
75
+ });
76
+ }
77
+ }
78
+ markerOptions.offset = data.offset ? new AMap.Pixel(data.offset[0], data.offset[1]) : new AMap.Pixel(-13, -34);
79
+ } else if (data.icon) {
80
+ if (typeof data.icon === "string") {
81
+ markerOptions.icon = data.icon;
82
+ } else {
83
+ const iconConfig = data.icon;
84
+ markerOptions.icon = new AMap.Icon({
85
+ // 图标尺寸
86
+ size: iconConfig.size ? new AMap.Size(iconConfig.size[0], iconConfig.size[1]) : new AMap.Size(25, 34),
87
+ // 图标的取图地址
88
+ image: iconConfig.image,
89
+ // 图标所用图片大小
90
+ imageSize: iconConfig.imageSize ? new AMap.Size(iconConfig.imageSize[0], iconConfig.imageSize[1]) : new AMap.Size(25, 34),
91
+ // 图标取图偏移量
92
+ imageOffset: iconConfig.imageOffset ? new AMap.Pixel(iconConfig.imageOffset[0], iconConfig.imageOffset[1]) : void 0
93
+ });
94
+ }
95
+ markerOptions.offset = data.offset ? new AMap.Pixel(data.offset[0], data.offset[1]) : new AMap.Pixel(-13, -34);
96
+ }
97
+ const marker = new AMap.Marker(markerOptions);
98
+ marker.on("click", (e) => {
99
+ emit("click", e, data);
100
+ });
101
+ marker.on("dragend", (e) => {
102
+ emit("dragend", e, data);
103
+ });
104
+ marker.on("mouseover", (e) => {
105
+ emit("mouseover", e, data);
106
+ });
107
+ marker.on("mouseout", (e) => {
108
+ emit("mouseout", e, data);
109
+ });
110
+ return marker;
111
+ }
112
+ function incrementalUpdate(newMarkers) {
113
+ if (!mapInstance)
114
+ return;
115
+ const existingMarkerIds = new Set(markers.value.map((marker) => {
116
+ var _a;
117
+ return (_a = marker.getExtData()) == null ? void 0 : _a.id;
118
+ }));
119
+ const newMarkerIds = new Set(newMarkers.map((m) => m.id));
120
+ markers.value.forEach((marker) => {
121
+ var _a;
122
+ const markerId = (_a = marker.getExtData()) == null ? void 0 : _a.id;
123
+ if (!newMarkerIds.has(markerId)) {
124
+ const cleanupFn = contentCleanupFns.get(marker);
125
+ if (cleanupFn) {
126
+ cleanupFn();
127
+ contentCleanupFns.delete(marker);
128
+ }
129
+ mapInstance == null ? void 0 : mapInstance.remove(marker);
130
+ }
131
+ });
132
+ const markersToAdd = newMarkers.filter((data) => {
133
+ return !existingMarkerIds.has(data.id);
134
+ });
135
+ if (markersToAdd.length > 0) {
136
+ const newMarkersList = [];
137
+ markersToAdd.forEach((data) => {
138
+ const marker = createMarker(data);
139
+ if (marker) {
140
+ newMarkersList.push(marker);
141
+ mapInstance == null ? void 0 : mapInstance.add(marker);
142
+ }
143
+ });
144
+ markers.value.push(...newMarkersList);
145
+ }
146
+ }
147
+ function fullUpdate(newMarkers) {
148
+ if (!mapInstance)
149
+ return;
150
+ removeMarkers();
151
+ if (newMarkers && newMarkers.length > 0) {
152
+ newMarkers.forEach((data) => {
153
+ const marker = createMarker(data);
154
+ if (marker) {
155
+ markers.value.push(marker);
156
+ mapInstance == null ? void 0 : mapInstance.add(marker);
157
+ }
158
+ });
159
+ }
160
+ }
161
+ function addMarkers() {
162
+ if (!mapInstance)
163
+ return;
164
+ if (props.markers && props.markers.length > 0) {
165
+ if (props.updateMode === "full") {
166
+ fullUpdate(props.markers);
167
+ } else {
168
+ incrementalUpdate(props.markers);
169
+ }
170
+ } else if (props.position) {
171
+ const singleMarker = {
172
+ position: props.position,
173
+ title: props.title,
174
+ draggable: props.draggable,
175
+ icon: props.icon,
176
+ visible: props.visible
177
+ };
178
+ const marker = createMarker(singleMarker);
179
+ if (marker) {
180
+ markers.value.push(marker);
181
+ mapInstance == null ? void 0 : mapInstance.add(marker);
182
+ }
183
+ }
184
+ }
185
+ function removeMarkers() {
186
+ if (!mapInstance || markers.value.length === 0)
187
+ return;
188
+ markers.value.forEach((marker) => {
189
+ const cleanupFn = contentCleanupFns.get(marker);
190
+ if (cleanupFn) {
191
+ cleanupFn();
192
+ contentCleanupFns.delete(marker);
193
+ }
194
+ mapInstance == null ? void 0 : mapInstance.remove(marker);
195
+ });
196
+ markers.value = [];
197
+ }
198
+ __expose({
199
+ getMarkers: () => markers.value,
200
+ clearMarkers: removeMarkers,
201
+ addMarker: (data) => {
202
+ const marker = createMarker(data);
203
+ if (marker && mapInstance) {
204
+ markers.value.push(marker);
205
+ mapInstance == null ? void 0 : mapInstance.add(marker);
206
+ }
207
+ return marker;
208
+ },
209
+ removeMarker: (marker) => {
210
+ if (mapInstance && marker) {
211
+ mapInstance == null ? void 0 : mapInstance.remove(marker);
212
+ const index = markers.value.indexOf(marker);
213
+ if (index > -1) {
214
+ markers.value.splice(index, 1);
215
+ }
216
+ }
217
+ }
218
+ });
219
+ onMounted(() => {
220
+ if (amapContext) {
221
+ if (mapInstance) {
222
+ addMarkers();
223
+ }
224
+ }
225
+ });
226
+ onUnmounted(() => {
227
+ removeMarkers();
228
+ });
229
+ watch(
230
+ () => props.markers,
231
+ (newMarkers, _oldMarkers) => {
232
+ if (!mapInstance)
233
+ return;
234
+ if (!newMarkers) {
235
+ removeMarkers();
236
+ return;
237
+ }
238
+ if (props.updateMode === "full") {
239
+ fullUpdate(newMarkers);
240
+ } else {
241
+ incrementalUpdate(newMarkers);
242
+ }
243
+ },
244
+ { immediate: true }
245
+ );
246
+ return (_ctx, _cache) => {
247
+ return renderSlot(_ctx.$slots, "default");
248
+ };
249
+ }
250
+ }));
251
+ export {
252
+ _sfc_main as default
253
+ };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from "./AMarker.vue.js";
2
+ /* empty css */
3
+ export {
4
+ _sfc_main as default
5
+ };
@@ -0,0 +1,7 @@
1
+ import { InstallWithSFC } from '../utils';
2
+ import { default as AMap } from './AMap.vue';
3
+ import { default as AMarker } from './AMarker.vue';
4
+ export declare const JkyAMap: InstallWithSFC<typeof AMap>;
5
+ export declare const JkyAMarker: InstallWithSFC<typeof AMarker>;
6
+ export default JkyAMap;
7
+ export { AMarker };