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