huawei-map-vue3
Version:
华为地图 Vue3 组件库 - 基于华为地图API开发的Vue3地图组件,提供完整的地图功能封装
2,221 lines • 82.6 kB
JavaScript
import { ref as U, onUnmounted as co, computed as B, defineComponent as X, watch as P, nextTick as eo, onMounted as Zo, createElementBlock as x, openBlock as _, normalizeStyle as Oo, createCommentVNode as D, createElementVNode as o, toDisplayString as h, withDirectives as $, vModelText as O, vModelSelect as N, vModelCheckbox as F, Fragment as K, renderList as J, normalizeClass as G, withModifiers as Q, createVNode as vo } from "vue";
function Po() {
return "DQEDAD1UhYOqf6mN2VJ1cy2A6BzTN7gSr28xX0KO4hUw1cDESelU6d5WeWn3mezhd3rxLtUSsDJpltkcZLYCoLxcNkpJsYkefIg1Pg==";
}
const R = {
apiKey: Po(),
apiUrl: "https://mapapi.cloud.huawei.com/mapjs/v1/api/js",
defaultCenter: {
lat: +"23.130415047434678" || 23.130415047434678,
lng: +"113.32380294799805" || 113.32380294799805
},
// 广州
defaultZoom: 8,
defaultLanguage: "zh",
defaultSourceType: "vector"
}, rl = {
standard: "standard",
night: "night",
simple: "simple"
}, ul = {
ROADMAP: "ROADMAP",
TERRAIN: "TERRAIN"
};
let to = !1, io = !1, oo = null;
function Ao(w) {
if (io && window.HWMapJsSDK)
return Promise.resolve();
if (to && oo)
return oo;
to = !0;
const t = w || R.apiKey;
return oo = new Promise((g, i) => {
const p = document.createElement("script");
p.type = "text/javascript", p.async = !0;
const M = `initHuaweiMap_${Date.now()}`;
window[M] = () => {
io = !0, to = !1, delete window[M], g();
}, p.src = `${R.apiUrl}?callback=${M}&key=${t}`, p.onerror = () => {
to = !1, oo = null, delete window[M], i(new Error("华为地图API加载失败"));
}, document.head.appendChild(p);
}), oo;
}
function dl() {
return io && !!window.HWMapJsSDK;
}
function Ro(w, t) {
const g = U([]), i = 100, p = U(), M = U(), f = U(), C = /* @__PURE__ */ new Map();
let l = 0;
const W = (S, V) => {
const L = {
id: `${Date.now()}-${S}-${++l}`,
type: S,
timestamp: Date.now(),
data: V
};
g.value.unshift(L), g.value.length > i && (g.value = g.value.slice(0, i));
}, I = (S) => ({ lat: S[1], lng: S[0] }), T = () => {
if (!w.value) return;
const S = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
W("click", E), t?.onClick?.(E);
};
w.value.on("click", S), z("click", S);
const V = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
W("dblclick", E), t?.onDoubleClick?.(E);
};
w.value.on("dblclick", V), z("dblclick", V);
const L = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
W("contextmenu", E), t?.onRightClick?.(E);
};
w.value.on("contextmenu", L), z("contextmenu", L);
const c = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
t?.onMouseMove?.(E);
};
w.value.on("pointermove", c), z("pointermove", c);
const d = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
W("mousedown", E), t?.onMouseDown?.(E);
};
w.value.on("pointerdown", d), z("pointerdown", d);
const v = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
W("mouseup", E), t?.onMouseUp?.(E);
};
w.value.on("pointerup", v), z("pointerup", v);
const k = (u) => {
const E = {
coordinate: u.coordinate,
pixel: u.pixel,
latLng: I(u.coordinate)
};
t?.onDrag?.(E);
};
w.value.on("pointerdrag", k), z("pointerdrag", k);
const H = () => {
W("movestart"), t?.onMoveStart?.();
};
w.value.on("movestart", H), z("movestart", H);
const b = () => {
W("moveend"), t?.onMoveEnd?.();
};
w.value.on("moveend", b), z("moveend", b);
const a = () => {
const u = w.value.getCenter();
p.value = u, W("centerChanged", u), t?.onCenterChanged?.(u);
};
w.value.onCenterChanged(a), z("centerChanged", a);
const e = () => {
const u = w.value.getZoom();
M.value = u, W("zoomChanged", u), t?.onZoomChanged?.(u);
};
w.value.onZoomChanged(e), z("zoomChanged", e);
const r = () => {
const u = w.value.getHeading();
f.value = u, W("headingChanged", u), t?.onHeadingChanged?.(u);
};
w.value.onHeadingChanged(r), z("headingChanged", r);
}, z = (S, V) => {
C.has(S) || C.set(S, []), C.get(S).push(V);
}, m = () => {
w.value && (C.forEach((S, V) => {
S.forEach((L) => {
V === "centerChanged" || V === "zoomChanged" || V === "headingChanged" || w.value.un(V, L);
});
}), C.clear());
}, n = () => {
g.value = [];
}, y = (S = 10) => g.value.slice(0, S), A = (S) => g.value.filter((V) => V.type === S);
return co(() => {
m();
}), {
// 响应式状态
eventHistory: g,
currentCenter: p,
currentZoom: M,
currentHeading: f,
// 方法
bindMapEvents: T,
unbindAllEvents: m,
clearHistory: n,
getRecentEvents: y,
getEventsByType: A,
addToHistory: W
};
}
function Fo(w, t) {
const g = U([]), i = U(/* @__PURE__ */ new Map()), p = U(null), M = B(
() => g.value.filter((b) => b.visible !== !1)
), f = B(() => g.value.length), C = B(() => M.value.length), l = () => "marker_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9), W = (b) => {
if (!w.value) return null;
const a = {
position: b.position,
map: w.value,
draggable: b.draggable || !1,
animation: b.animation || null,
zIndex: b.zIndex || 0
};
b.icon && (a.icon = b.icon), b.label && (a.label = b.label), b.properties && (a.properties = b.properties);
const e = new window.HWMapJsSDK.HWMarker(a);
return I(e, b), e;
}, I = (b, a) => {
t && (t.onClick && b.addListener("click", (e) => {
t.onClick(a, e);
}), t.onDoubleClick && b.addListener("dbclick", (e) => {
t.onDoubleClick(a, e);
}), t.onRightClick && b.addListener("contextmenu", (e) => {
t.onRightClick(a, e);
}), t.onMouseOver && b.addListener("mouseOver", (e) => {
t.onMouseOver(a, e);
}), t.onMouseOut && b.addListener("mouseOut", (e) => {
t.onMouseOut(a, e);
}), a.draggable && (t.onDragStart && b.addListener("dragstart", (e) => {
t.onDragStart(a, e);
}), t.onDrag && b.addListener("drag", (e) => {
t.onDrag(a, e);
}), t.onDragEnd && b.addListener("dragend", (e) => {
const r = b.getPosition();
a.position = r, t.onDragEnd(a, e);
})));
}, T = (b) => {
const a = b.id || l(), e = {
...b,
id: a,
visible: b.visible !== !1
}, r = W(e);
return r && (i.value.set(a, r), g.value.push(e)), a;
}, z = (b) => b.map((a) => T(a)), m = (b) => {
const a = i.value.get(b);
a && (a.setMap(null), i.value.delete(b));
const e = g.value.findIndex((r) => r.id === b);
return e > -1 ? (g.value.splice(e, 1), p.value?.id === b && (p.value = null), !0) : !1;
}, n = (b) => {
let a = 0;
return b.forEach((e) => {
m(e) && a++;
}), a;
}, y = () => {
const b = g.value.length;
return i.value.forEach((a) => {
a.setMap(null);
}), i.value.clear(), g.value = [], p.value = null, b;
}, A = (b, a) => {
const e = g.value.findIndex((E) => E.id === b);
if (e === -1) return !1;
const r = g.value[e], u = i.value.get(b);
return u ? (Object.assign(r, a), a.position && u.setPosition(a.position), a.icon !== void 0 && u.setIcon(a.icon), a.label !== void 0 && u.setLabel(a.label), a.draggable !== void 0 && u.setDraggable(a.draggable), a.animation !== void 0 && u.setAnimation(a.animation), a.zIndex !== void 0 && u.setZIndex(a.zIndex), a.visible !== void 0 && u.setMap(a.visible ? w.value : null), !0) : !1;
}, S = (b) => g.value.find((a) => a.id === b), V = (b) => i.value.get(b), L = (b) => {
const a = S(b);
if (!a) return !1;
const e = !a.visible;
return A(b, { visible: e });
}, c = (b) => {
const a = S(b);
return a ? (p.value = a, !0) : !1;
}, d = () => {
p.value = null;
}, v = (b, a = 1e-4) => g.value.filter((e) => {
const r = Math.abs(e.position.lat - b.lat), u = Math.abs(e.position.lng - b.lng);
return r <= a && u <= a;
}), k = () => {
if (M.value.length === 0) return null;
let b = 1 / 0, a = -1 / 0, e = 1 / 0, r = -1 / 0;
return M.value.forEach((u) => {
b = Math.min(b, u.position.lat), a = Math.max(a, u.position.lat), e = Math.min(e, u.position.lng), r = Math.max(r, u.position.lng);
}), {
ne: { lat: a, lng: r },
sw: { lat: b, lng: e }
};
};
return {
// 响应式状态
markers: g,
visibleMarkers: M,
selectedMarker: p,
markerCount: f,
visibleMarkerCount: C,
// 方法
addMarker: T,
addMarkers: z,
removeMarker: m,
removeMarkers: n,
clearMarkers: y,
updateMarker: A,
getMarker: S,
getMarkerInstance: V,
toggleMarkerVisibility: L,
selectMarker: c,
deselectMarker: d,
findMarkersByPosition: v,
getMarkersBounds: k,
fitMarkersToView: () => {
if (!w.value) return !1;
const b = k();
return b ? (w.value.fitBounds(b), !0) : !1;
}
};
}
function Do(w, t) {
const g = U([]), i = U(/* @__PURE__ */ new Map()), p = U(null), M = B(
() => g.value.filter((e) => e.visible !== !1)
), f = B(() => g.value.length), C = B(() => M.value.length), l = () => "infowindow_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9), W = (e) => {
if (!w.value) return null;
const r = {
position: e.position,
content: e.content,
map: w.value
};
e.offset && (r.offset = e.offset);
const u = new window.HWMapJsSDK.HWInfoWindow(r);
return I(u, e), u;
}, I = (e, r) => {
t && t.onClose && e.addListener("close", () => {
r.visible = !1, p.value?.id === r.id && (p.value = null), t.onClose(r);
});
}, T = (e) => {
const r = e.id || l(), u = {
...e,
id: r,
visible: e.visible !== !1,
closable: e.closable !== !1
}, E = W(u);
return E && (i.value.set(r, E), g.value.push(u)), r;
}, z = (e, r) => {
const u = V(e), E = i.value.get(e);
return !u || !E ? !1 : (n(), r ? E.open(r) : E.open(), u.visible = !0, p.value = u, t?.onOpen?.(u), !0);
}, m = (e) => {
const r = V(e), u = i.value.get(e);
return !r || !u ? !1 : (u.close(), r.visible = !1, p.value?.id === e && (p.value = null), t?.onClose?.(r), !0);
}, n = () => {
let e = 0;
return g.value.forEach((r) => {
r.visible && (m(r.id), e++);
}), e;
}, y = (e) => {
const r = i.value.get(e);
r && (r.close(), i.value.delete(e));
const u = g.value.findIndex((E) => E.id === e);
return u > -1 ? (g.value.splice(u, 1), p.value?.id === e && (p.value = null), !0) : !1;
}, A = () => {
const e = g.value.length;
return i.value.forEach((r) => {
r.close();
}), i.value.clear(), g.value = [], p.value = null, e;
}, S = (e, r) => {
const u = g.value.findIndex((lo) => lo.id === e);
if (u === -1) return !1;
const E = g.value[u], Y = i.value.get(e);
return Y ? (Object.assign(E, r), r.position && Y.setPosition(r.position), r.content !== void 0 && (Y.setContent(r.content), t?.onContentChange?.(E, r.content)), !0) : !1;
}, V = (e) => g.value.find((r) => r.id === e), L = (e) => i.value.get(e), c = (e) => g.value.filter((r) => r.markerId === e);
return {
// 响应式状态
infoWindows: g,
visibleInfoWindows: M,
activeInfoWindow: p,
infoWindowCount: f,
visibleInfoWindowCount: C,
// 方法
addInfoWindow: T,
openInfoWindow: z,
closeInfoWindow: m,
closeAllInfoWindows: n,
removeInfoWindow: y,
clearInfoWindows: A,
updateInfoWindow: S,
getInfoWindow: V,
getInfoWindowInstance: L,
findInfoWindowsByMarkerId: c,
createInfoWindowForMarker: (e, r, u, E) => {
const Y = {
position: r,
content: u,
markerId: e,
...E
};
return T(Y);
},
showMarkerInfoWindow: (e, r) => {
const u = c(e);
return u.length === 0 ? !1 : z(u[0].id, r);
},
hideMarkerInfoWindow: (e) => {
const r = c(e);
let u = 0;
return r.forEach((E) => {
m(E.id) && u++;
}), u > 0;
},
toggleInfoWindow: (e, r) => {
const u = V(e);
return u ? u.visible ? m(e) : z(e, r) : !1;
},
setInfoWindowContent: (e, r) => S(e, { content: r }),
moveInfoWindow: (e, r) => S(e, { position: r })
};
}
const Ho = {
key: 0,
class: "map-loading"
}, Bo = {
key: 1,
class: "map-error"
}, No = /* @__PURE__ */ X({
__name: "HuaweiMap",
props: {
width: { default: "100%" },
height: { default: "400px" },
center: { default: () => R.defaultCenter },
zoom: { default: R.defaultZoom },
language: { default: R.defaultLanguage },
sourceType: { default: R.defaultSourceType },
mapType: { default: "ROADMAP" },
minZoom: { default: 2 },
maxZoom: { default: 22 },
copyrightControl: { type: Boolean, default: !1 },
locationControl: { type: Boolean, default: !1 },
navigationControl: { type: Boolean, default: !1 },
rotateControl: { type: Boolean, default: !1 },
scaleControl: { type: Boolean, default: !1 },
zoomControl: { type: Boolean, default: !0 },
zoomSlider: { type: Boolean, default: !1 },
logoPosition: { default: "BOTTOM_LEFT" },
presetStyleId: { default: "standard" },
opacity: { default: 1 },
apiKey: {},
enableEventMonitor: { type: Boolean, default: !1 }
},
emits: ["map-ready", "map-click", "map-dblclick", "map-rightclick", "map-mousemove", "map-mousedown", "map-mouseup", "map-drag", "move-start", "move-end", "center-changed", "zoom-changed", "heading-changed", "map-error", "marker-click", "marker-dblclick", "marker-rightclick", "marker-dragstart", "marker-drag", "marker-dragend", "infowindow-open", "infowindow-close", "infowindow-content-change"],
setup(w, { expose: t, emit: g }) {
const i = w, p = g, M = U(), f = U(!0), C = U(""), l = U(), W = {
onClick: (s) => p("map-click", s),
onDoubleClick: (s) => p("map-dblclick", s),
onRightClick: (s) => p("map-rightclick", s),
onMouseMove: (s) => p("map-mousemove", s),
onMouseDown: (s) => p("map-mousedown", s),
onMouseUp: (s) => p("map-mouseup", s),
onDrag: (s) => p("map-drag", s),
onMoveStart: () => p("move-start"),
onMoveEnd: () => p("move-end"),
onCenterChanged: (s) => p("center-changed", s),
onZoomChanged: (s) => p("zoom-changed", s),
onHeadingChanged: (s) => p("heading-changed", s)
}, {
eventHistory: I,
currentCenter: T,
currentZoom: z,
currentHeading: m,
bindMapEvents: n,
unbindAllEvents: y,
clearHistory: A
} = Ro(l, i.enableEventMonitor ? W : void 0), S = {
onClick: (s, Z) => {
p("marker-click", s, Z);
const uo = u(s.id);
uo && ao(s.id, uo);
},
onDoubleClick: (s, Z) => p("marker-dblclick", s, Z),
onRightClick: (s, Z) => p("marker-rightclick", s, Z),
onDragStart: (s, Z) => p("marker-dragstart", s, Z),
onDrag: (s, Z) => p("marker-drag", s, Z),
onDragEnd: (s, Z) => p("marker-dragend", s, Z)
}, {
markers: V,
visibleMarkers: L,
selectedMarker: c,
markerCount: d,
visibleMarkerCount: v,
addMarker: k,
addMarkers: H,
removeMarker: b,
removeMarkers: a,
clearMarkers: e,
updateMarker: r,
getMarker: u,
toggleMarkerVisibility: E,
selectMarker: Y,
deselectMarker: lo,
fitMarkersToView: mo
} = Fo(l, S), fo = {
onOpen: (s) => p("infowindow-open", s),
onClose: (s) => p("infowindow-close", s),
onContentChange: (s, Z) => p("infowindow-content-change", s, Z)
}, {
infoWindows: go,
visibleInfoWindows: bo,
activeInfoWindow: yo,
infoWindowCount: ko,
visibleInfoWindowCount: Co,
addInfoWindow: wo,
openInfoWindow: $o,
closeInfoWindow: Mo,
closeAllInfoWindows: ho,
removeInfoWindow: Io,
clearInfoWindows: xo,
updateInfoWindow: _o,
getInfoWindow: Wo,
createInfoWindowForMarker: To,
showMarkerInfoWindow: ao,
hideMarkerInfoWindow: zo,
toggleInfoWindow: Eo,
setInfoWindowContent: Uo,
moveInfoWindow: Lo
} = Do(l, fo), j = async () => {
try {
if (f.value = !0, C.value = "", !M.value)
throw new Error("地图容器未找到");
await Ao(i.apiKey), await eo();
const s = {
center: i.center,
zoom: i.zoom,
language: i.language,
sourceType: i.sourceType,
mapType: i.mapType,
minZoom: i.minZoom,
maxZoom: i.maxZoom,
copyrightControl: i.copyrightControl,
locationControl: i.locationControl,
navigationControl: i.navigationControl,
rotateControl: i.rotateControl,
scaleControl: i.scaleControl,
zoomControl: i.zoomControl,
zoomSlider: i.zoomSlider,
logoPosition: i.logoPosition,
presetStyleId: i.presetStyleId,
// 优化渲染质量
rasterPreload: !0,
// 启用栅格预加载
pixelRatio: window.devicePixelRatio || 1
// 支持高分辨率屏幕
};
l.value = new window.HWMapJsSDK.HWMap(M.value, s), i.opacity !== 1 && l.value.setOpacity(i.opacity), setTimeout(() => {
l.value && l.value.resize();
}, 100), setTimeout(() => {
l.value && l.value.resize();
}, 300), setTimeout(() => {
l.value && l.value.resize();
}, 500), i.enableEventMonitor ? n() : So(), f.value = !1, p("map-ready", l.value);
} catch (s) {
f.value = !1;
const Z = s instanceof Error ? s.message : "地图初始化失败";
C.value = Z, p("map-error", Z), console.error("华为地图初始化失败:", s);
}
}, So = () => {
l.value && (l.value.on("click", (s) => {
p("map-click", s);
}), l.value.on("dblclick", (s) => {
p("map-dblclick", s);
}), l.value.on("contextmenu", (s) => {
p("map-rightclick", s);
}), l.value.onCenterChanged(() => {
const s = l.value.getCenter();
p("center-changed", s);
}), l.value.onZoomChanged(() => {
const s = l.value.getZoom();
p("zoom-changed", s);
}));
}, Vo = () => {
j();
};
P(() => i.center, (s) => {
l.value && s && l.value.setCenter(s);
}), P(() => i.zoom, (s) => {
l.value && s && l.value.setZoom(s);
}), P(() => i.opacity, (s) => {
l.value && s !== void 0 && l.value.setOpacity(s);
}), P(() => i.mapType, (s, Z) => {
l.value && s !== Z && (console.log("地图类型发生变化,重新初始化地图:", s), j());
}), P([() => i.width, () => i.height], () => {
l.value && eo(() => {
setTimeout(() => {
l.value && l.value.resize();
}, 100);
});
}), P(() => i.presetStyleId, (s) => {
l.value && s && (console.log("设置预设样式:", s), l.value.setPresetStyleId(s));
}), P(() => i.logoPosition, (s) => {
l.value && s && (console.log("设置Logo位置:", s), l.value.setLogoPosition(s));
}), P(() => i.copyrightControl, (s) => {
l.value && s !== void 0 && (console.log("设置版权控件:", s), l.value.setCopyrightControl(s));
}), P(() => i.locationControl, (s) => {
l.value && s !== void 0 && (console.log("设置定位控件:", s), l.value.setLocationControl(s));
}), P(() => i.navigationControl, (s) => {
l.value && s !== void 0 && (console.log("设置导航控件:", s), l.value.setNavigationControl(s));
}), P(() => i.rotateControl, (s) => {
l.value && s !== void 0 && (console.log("设置旋转控件:", s), l.value.setRotateControl(s));
}), P(() => i.scaleControl, (s) => {
l.value && s !== void 0 && (console.log("设置比例尺控件:", s), l.value.setScaleControl(s));
}), P(() => i.zoomControl, (s) => {
l.value && s !== void 0 && (console.log("设置缩放控件:", s), l.value.setZoomControl(s));
}), P(() => i.zoomSlider, (s) => {
l.value && s !== void 0 && (console.log("设置缩放条:", s), l.value.setZoomSlider(s));
}), P(() => i.sourceType, (s, Z) => {
l.value && s !== Z && (console.log("瓦片类型发生变化,重新初始化地图:", s), j());
}), P(() => i.language, (s, Z) => {
l.value && s !== Z && (console.log("语言设置发生变化,重新初始化地图:", s), j());
}), P(() => i.minZoom, (s, Z) => {
l.value && s !== Z && (console.log("最小缩放级别发生变化,重新初始化地图:", s), j());
}), P(() => i.maxZoom, (s, Z) => {
l.value && s !== Z && (console.log("最大缩放级别发生变化,重新初始化地图:", s), j());
});
const ro = () => {
l.value && l.value.resize();
};
return Zo(() => {
j(), window.addEventListener("resize", ro);
}), co(() => {
window.removeEventListener("resize", ro), l.value && (l.value = void 0);
}), t({
map: l,
getMap: () => l.value,
reload: j,
// 事件相关
eventHistory: I,
currentCenter: T,
currentZoom: z,
currentHeading: m,
clearEventHistory: A,
// 标记相关
markers: V,
visibleMarkers: L,
selectedMarker: c,
markerCount: d,
visibleMarkerCount: v,
addMarker: k,
addMarkers: H,
removeMarker: b,
removeMarkers: a,
clearMarkers: e,
updateMarker: r,
getMarker: u,
toggleMarkerVisibility: E,
selectMarker: Y,
deselectMarker: lo,
fitMarkersToView: mo,
// 信息窗相关
infoWindows: go,
visibleInfoWindows: bo,
activeInfoWindow: yo,
infoWindowCount: ko,
visibleInfoWindowCount: Co,
addInfoWindow: wo,
openInfoWindow: $o,
closeInfoWindow: Mo,
closeAllInfoWindows: ho,
removeInfoWindow: Io,
clearInfoWindows: xo,
updateInfoWindow: _o,
getInfoWindow: Wo,
createInfoWindowForMarker: To,
showMarkerInfoWindow: ao,
hideMarkerInfoWindow: zo,
toggleInfoWindow: Eo,
setInfoWindowContent: Uo,
moveInfoWindow: Lo
}), (s, Z) => (_(), x("div", {
ref_key: "mapContainer",
ref: M,
class: "huawei-map-container",
style: Oo({ width: s.width, height: s.height })
}, [
f.value ? (_(), x("div", Ho, Z[0] || (Z[0] = [
o("div", { class: "loading-spinner" }, null, -1),
o("p", null, "地图加载中...", -1)
]))) : D("", !0),
C.value ? (_(), x("div", Bo, [
o("p", null, h(C.value), 1),
o("button", {
onClick: Vo,
class: "retry-button"
}, "重试")
])) : D("", !0)
], 4));
}
}), q = (w, t) => {
const g = w.__vccOpts || w;
for (const [i, p] of t)
g[i] = p;
return g;
}, po = /* @__PURE__ */ q(No, [["__scopeId", "data-v-eb288c91"]]), so = {
copyright: !1,
location: !1,
navigation: !1,
rotate: !1,
scale: !1,
zoom: !0,
zoomSlider: !1
}, no = {
logoPosition: "BOTTOM_LEFT",
presetStyleId: "standard",
opacity: 1
};
function Ko(w) {
const t = U({
center: w?.center || R.defaultCenter,
zoom: w?.zoom || R.defaultZoom,
language: w?.language || R.defaultLanguage,
sourceType: w?.sourceType || R.defaultSourceType,
mapType: w?.mapType || "ROADMAP",
minZoom: w?.minZoom || 2,
maxZoom: w?.maxZoom || 20,
controls: { ...so, ...w?.controls },
style: { ...no, ...w?.style },
apiKey: w?.apiKey || R.apiKey
}), g = B(() => ({
center: t.value.center,
zoom: t.value.zoom,
language: t.value.language,
sourceType: t.value.sourceType,
mapType: t.value.mapType,
minZoom: t.value.minZoom,
maxZoom: t.value.maxZoom,
copyrightControl: t.value.controls?.copyright,
locationControl: t.value.controls?.location,
navigationControl: t.value.controls?.navigation,
rotateControl: t.value.controls?.rotate,
scaleControl: t.value.controls?.scale,
zoomControl: t.value.controls?.zoom,
zoomSlider: t.value.controls?.zoomSlider,
logoPosition: t.value.style?.logoPosition,
presetStyleId: t.value.style?.presetStyleId
}));
return {
// 响应式状态
config: t,
hwMapOptions: g,
// 方法
updateConfig: (m) => {
t.value = {
...t.value,
...m,
controls: { ...t.value.controls, ...m.controls },
style: { ...t.value.style, ...m.style }
};
},
resetConfig: () => {
t.value = {
center: R.defaultCenter,
zoom: R.defaultZoom,
language: R.defaultLanguage,
sourceType: R.defaultSourceType,
mapType: "ROADMAP",
minZoom: 2,
maxZoom: 20,
controls: { ...so },
style: { ...no },
apiKey: R.apiKey
};
},
setCenter: (m) => {
t.value.center = m;
},
setZoom: (m) => {
t.value.zoom = Math.max(
t.value.minZoom || 2,
Math.min(t.value.maxZoom || 20, m)
);
},
setMapType: (m) => {
t.value.mapType = m;
},
setPresetStyle: (m) => {
t.value.style || (t.value.style = { ...no }), t.value.style.presetStyleId = m;
},
toggleControl: (m, n) => {
t.value.controls || (t.value.controls = { ...so }), t.value.controls[m] = n !== void 0 ? n : !t.value.controls[m];
},
setOpacity: (m) => {
t.value.style || (t.value.style = { ...no }), t.value.style.opacity = Math.max(0, Math.min(1, m));
},
validateConfig: () => {
const m = [];
return t.value.center ? ((t.value.center.lat < -90 || t.value.center.lat > 90) && m.push("纬度必须在-90到90之间"), (t.value.center.lng < -180 || t.value.center.lng > 180) && m.push("经度必须在-180到180之间")) : m.push("地图中心点不能为空"), t.value.zoom !== void 0 && (t.value.zoom < (t.value.minZoom || 2) || t.value.zoom > (t.value.maxZoom || 20)) && m.push(`缩放级别必须在${t.value.minZoom || 2}到${t.value.maxZoom || 20}之间`), t.value.style?.opacity !== void 0 && (t.value.style.opacity < 0 || t.value.style.opacity > 1) && m.push("透明度必须在0到1之间"), {
isValid: m.length === 0,
errors: m
};
},
getConfigSummary: () => ({
center: t.value.center,
zoom: t.value.zoom,
mapType: t.value.mapType,
sourceType: t.value.sourceType,
enabledControls: Object.entries(t.value.controls || {}).filter(([, m]) => m).map(([m]) => m),
style: t.value.style
})
};
}
const Jo = { class: "map-config-panel" }, jo = { class: "config-section" }, Yo = { class: "config-group" }, Go = { class: "coordinate-inputs" }, Xo = { class: "input-group" }, qo = { class: "input-group" }, Qo = { class: "config-group" }, oe = { class: "zoom-control" }, ee = ["min", "max"], te = { class: "zoom-value" }, ne = { class: "config-group" }, le = { class: "config-group" }, se = { class: "config-group" }, ie = { class: "config-section" }, ae = { class: "controls-grid" }, re = { class: "control-item" }, ue = { class: "control-item" }, de = { class: "control-item" }, ce = { class: "control-item" }, ve = { class: "control-item" }, pe = { class: "control-item" }, me = { class: "control-item" }, fe = { class: "config-section" }, ge = { class: "config-group" }, be = { class: "config-group" }, ye = { class: "config-group" }, ke = { class: "opacity-control" }, Ce = { class: "opacity-value" }, we = {
key: 0,
class: "validation-errors"
}, $e = /* @__PURE__ */ X({
__name: "MapConfigPanel",
props: {
modelValue: { default: () => ({}) }
},
emits: ["update:modelValue", "config-change"],
setup(w, { emit: t }) {
const g = w, i = t, { config: p, updateConfig: M, resetConfig: f, validateConfig: C } = Ko(g.modelValue), l = U({ ...p.value }), W = B(() => C().errors);
let I = !1;
P(l, (m) => {
I || (i("update:modelValue", m), i("config-change", m));
}, { deep: !0 }), P(() => g.modelValue, (m) => {
m && !I && (I = !0, Object.assign(l.value, m), eo(() => {
I = !1;
}));
}, { deep: !0 });
const T = () => {
C().isValid && (M(l.value), i("config-change", l.value));
}, z = () => {
f(), l.value = { ...p.value };
};
return (m, n) => (_(), x("div", Jo, [
o("div", jo, [
n[28] || (n[28] = o("h3", null, "基础配置", -1)),
o("div", Yo, [
n[18] || (n[18] = o("label", null, "地图中心点", -1)),
o("div", Go, [
o("div", Xo, [
n[16] || (n[16] = o("label", null, "纬度", -1)),
$(o("input", {
"onUpdate:modelValue": n[0] || (n[0] = (y) => l.value.center.lat = y),
type: "number",
step: "0.000001",
min: "-90",
max: "90",
class: "coordinate-input"
}, null, 512), [
[
O,
l.value.center.lat,
void 0,
{ number: !0 }
]
])
]),
o("div", qo, [
n[17] || (n[17] = o("label", null, "经度", -1)),
$(o("input", {
"onUpdate:modelValue": n[1] || (n[1] = (y) => l.value.center.lng = y),
type: "number",
step: "0.000001",
min: "-180",
max: "180",
class: "coordinate-input"
}, null, 512), [
[
O,
l.value.center.lng,
void 0,
{ number: !0 }
]
])
])
])
]),
o("div", Qo, [
n[19] || (n[19] = o("label", null, "缩放级别", -1)),
o("div", oe, [
$(o("input", {
"onUpdate:modelValue": n[2] || (n[2] = (y) => l.value.zoom = y),
type: "range",
min: l.value.minZoom,
max: l.value.maxZoom,
class: "zoom-slider"
}, null, 8, ee), [
[
O,
l.value.zoom,
void 0,
{ number: !0 }
]
]),
o("span", te, h(l.value.zoom), 1)
])
]),
o("div", ne, [
n[21] || (n[21] = o("label", null, "地图类型", -1)),
$(o("select", {
"onUpdate:modelValue": n[3] || (n[3] = (y) => l.value.mapType = y),
class: "select-input"
}, n[20] || (n[20] = [
o("option", { value: "ROADMAP" }, "基础地图(道路、建筑)", -1),
o("option", { value: "TERRAIN" }, "地形图(地形、海拔)", -1)
]), 512), [
[N, l.value.mapType]
]),
n[22] || (n[22] = o("small", { class: "config-hint" }, "切换地图类型会重新加载地图", -1))
]),
o("div", le, [
n[24] || (n[24] = o("label", null, "瓦片类型", -1)),
$(o("select", {
"onUpdate:modelValue": n[4] || (n[4] = (y) => l.value.sourceType = y),
class: "select-input"
}, n[23] || (n[23] = [
o("option", { value: "vector" }, "矢量(清晰、快速)", -1),
o("option", { value: "raster" }, "栅格(兼容性好)", -1)
]), 512), [
[N, l.value.sourceType]
]),
n[25] || (n[25] = o("small", { class: "config-hint" }, "矢量瓦片在高缩放级别更清晰", -1))
]),
o("div", se, [
n[27] || (n[27] = o("label", null, "语言", -1)),
$(o("select", {
"onUpdate:modelValue": n[5] || (n[5] = (y) => l.value.language = y),
class: "select-input"
}, n[26] || (n[26] = [
o("option", { value: "zh" }, "中文", -1),
o("option", { value: "en" }, "English", -1)
]), 512), [
[N, l.value.language]
])
])
]),
o("div", ie, [
n[36] || (n[36] = o("h3", null, "控件配置", -1)),
o("div", ae, [
o("label", re, [
$(o("input", {
"onUpdate:modelValue": n[6] || (n[6] = (y) => l.value.controls.copyright = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.copyright]
]),
n[29] || (n[29] = o("span", null, "版权信息", -1))
]),
o("label", ue, [
$(o("input", {
"onUpdate:modelValue": n[7] || (n[7] = (y) => l.value.controls.location = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.location]
]),
n[30] || (n[30] = o("span", null, "定位按钮", -1))
]),
o("label", de, [
$(o("input", {
"onUpdate:modelValue": n[8] || (n[8] = (y) => l.value.controls.navigation = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.navigation]
]),
n[31] || (n[31] = o("span", null, "导航按钮", -1))
]),
o("label", ce, [
$(o("input", {
"onUpdate:modelValue": n[9] || (n[9] = (y) => l.value.controls.rotate = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.rotate]
]),
n[32] || (n[32] = o("span", null, "指北针", -1))
]),
o("label", ve, [
$(o("input", {
"onUpdate:modelValue": n[10] || (n[10] = (y) => l.value.controls.scale = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.scale]
]),
n[33] || (n[33] = o("span", null, "比例尺", -1))
]),
o("label", pe, [
$(o("input", {
"onUpdate:modelValue": n[11] || (n[11] = (y) => l.value.controls.zoom = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.zoom]
]),
n[34] || (n[34] = o("span", null, "缩放按钮", -1))
]),
o("label", me, [
$(o("input", {
"onUpdate:modelValue": n[12] || (n[12] = (y) => l.value.controls.zoomSlider = y),
type: "checkbox"
}, null, 512), [
[F, l.value.controls.zoomSlider]
]),
n[35] || (n[35] = o("span", null, "缩放条", -1))
])
])
]),
o("div", fe, [
n[42] || (n[42] = o("h3", null, "样式配置", -1)),
o("div", ge, [
n[38] || (n[38] = o("label", null, "预设样式", -1)),
$(o("select", {
"onUpdate:modelValue": n[13] || (n[13] = (y) => l.value.style.presetStyleId = y),
class: "select-input"
}, n[37] || (n[37] = [
o("option", { value: "standard" }, "标准", -1),
o("option", { value: "night" }, "夜间", -1),
o("option", { value: "simple" }, "简洁", -1)
]), 512), [
[N, l.value.style.presetStyleId]
])
]),
o("div", be, [
n[40] || (n[40] = o("label", null, "Logo位置", -1)),
$(o("select", {
"onUpdate:modelValue": n[14] || (n[14] = (y) => l.value.style.logoPosition = y),
class: "select-input"
}, n[39] || (n[39] = [
o("option", { value: "BOTTOM_LEFT" }, "左下", -1),
o("option", { value: "BOTTOM_RIGHT" }, "右下", -1),
o("option", { value: "TOP_LEFT" }, "左上", -1),
o("option", { value: "TOP_RIGHT" }, "右上", -1)
]), 512), [
[N, l.value.style.logoPosition]
])
]),
o("div", ye, [
n[41] || (n[41] = o("label", null, "透明度", -1)),
o("div", ke, [
$(o("input", {
"onUpdate:modelValue": n[15] || (n[15] = (y) => l.value.style.opacity = y),
type: "range",
min: "0",
max: "1",
step: "0.1",
class: "opacity-slider"
}, null, 512), [
[
O,
l.value.style.opacity,
void 0,
{ number: !0 }
]
]),
o("span", Ce, h(((l.value.style?.opacity || 1) * 100).toFixed(0)) + "%", 1)
])
])
]),
o("div", { class: "config-actions" }, [
o("button", {
onClick: z,
class: "action-button secondary"
}, " 重置默认 "),
o("button", {
onClick: T,
class: "action-button primary"
}, " 应用配置 ")
]),
W.value.length > 0 ? (_(), x("div", we, [
n[43] || (n[43] = o("h4", null, "配置错误:", -1)),
o("ul", null, [
(_(!0), x(K, null, J(W.value, (y) => (_(), x("li", { key: y }, h(y), 1))), 128))
])
])) : D("", !0)
]));
}
}), cl = /* @__PURE__ */ q($e, [["__scopeId", "data-v-0b9254b5"]]), Me = { class: "map-event-monitor" }, he = { class: "monitor-header" }, Ie = { class: "monitor-controls" }, xe = { class: "current-state" }, _e = { class: "state-grid" }, We = { class: "state-item" }, Te = { key: 0 }, ze = { key: 1 }, Ee = { class: "state-item" }, Ue = { class: "state-item" }, Le = { class: "event-filters" }, Se = { class: "filter-checkboxes" }, Ve = ["value"], Ze = { class: "event-list-container" }, Oe = { class: "event-header" }, Pe = { class: "event-type" }, Ae = { class: "event-time" }, Re = {
key: 0,
class: "event-data"
}, Fe = {
key: 0,
class: "data-item"
}, De = {
key: 1,
class: "data-item"
}, He = {
key: 2,
class: "data-item"
}, Be = {
key: 0,
class: "no-events"
}, Ne = /* @__PURE__ */ X({
__name: "MapEventMonitor",
props: {
eventHistory: {},
currentCenter: {},
currentZoom: {},
currentHeading: {}
},
emits: ["clear-events"],
setup(w, { emit: t }) {
const g = w, i = t, p = U(), M = U(!0), f = U([
"click",
"dblclick",
"contextmenu",
"centerChanged",
"zoomChanged"
]), C = [
"click",
"dblclick",
"contextmenu",
"mousedown",
"mouseup",
"movestart",
"moveend",
"centerChanged",
"zoomChanged",
"headingChanged"
], l = {
click: "单击",
dblclick: "双击",
contextmenu: "右键",
mousedown: "鼠标按下",
mouseup: "鼠标松开",
movestart: "开始移动",
moveend: "结束移动",
centerChanged: "中心点变化",
zoomChanged: "缩放变化",
headingChanged: "方向变化"
}, W = B(() => g.eventHistory.filter(
(m) => f.value.includes(m.type)
)), I = () => {
i("clear-events");
}, T = () => {
M.value = !M.value;
}, z = (m) => {
const n = new Date(m);
return n.toLocaleTimeString("zh-CN", {
hour12: !1,
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
}) + "." + n.getMilliseconds().toString().padStart(3, "0");
};
return P(W, async () => {
M.value && p.value && (await eo(), p.value.scrollTop = 0);
}), (m, n) => (_(), x("div", Me, [
o("div", he, [
n[1] || (n[1] = o("h3", null, "事件监控", -1)),
o("div", Ie, [
o("button", {
onClick: I,
class: "clear-button"
}, " 清空记录 "),
o("button", {
onClick: T,
class: G(["toggle-button", { active: M.value }])
}, " 自动滚动 ", 2)
])
]),
o("div", xe, [
n[5] || (n[5] = o("h4", null, "当前状态", -1)),
o("div", _e, [
o("div", We, [
n[2] || (n[2] = o("label", null, "中心点:", -1)),
m.currentCenter ? (_(), x("span", Te, h(m.currentCenter.lat.toFixed(6)) + ", " + h(m.currentCenter.lng.toFixed(6)), 1)) : (_(), x("span", ze, "-"))
]),
o("div", Ee, [
n[3] || (n[3] = o("label", null, "缩放级别:", -1)),
o("span", null, h(m.currentZoom || "-"), 1)
]),
o("div", Ue, [
n[4] || (n[4] = o("label", null, "方向:", -1)),
o("span", null, h(m.currentHeading ? m.currentHeading.toFixed(2) + "°" : "-"), 1)
])
])
]),
o("div", Le, [
n[6] || (n[6] = o("h4", null, "事件过滤", -1)),
o("div", Se, [
(_(), x(K, null, J(C, (y) => o("label", {
key: y,
class: "filter-checkbox"
}, [
$(o("input", {
"onUpdate:modelValue": n[0] || (n[0] = (A) => f.value = A),
value: y,
type: "checkbox"
}, null, 8, Ve), [
[F, f.value]
]),
o("span", null, h(l[y]), 1)
])), 64))
])
]),
o("div", Ze, [
o("h4", null, "事件记录 (" + h(W.value.length) + ")", 1),
o("div", {
ref_key: "eventListRef",
ref: p,
class: G(["event-list", { "auto-scroll": M.value }])
}, [
(_(!0), x(K, null, J(W.value, (y) => (_(), x("div", {
key: y.id,
class: G(["event-item", `event-${y.type}`])
}, [
o("div", Oe, [
o("span", Pe, h(l[y.type] || y.type), 1),
o("span", Ae, h(z(y.timestamp)), 1)
]),
y.data ? (_(), x("div", Re, [
y.data.latLng ? (_(), x("span", Fe, " 坐标: " + h(y.data.latLng.lat.toFixed(6)) + ", " + h(y.data.latLng.lng.toFixed(6)), 1)) : y.data.lat !== void 0 ? (_(), x("span", De, " 中心点: " + h(y.data.lat.toFixed(6)) + ", " + h(y.data.lng.toFixed(6)), 1)) : typeof y.data == "number" ? (_(), x("span", He, " 值: " + h(y.data), 1)) : D("", !0)
])) : D("", !0)
], 2))), 128)),
W.value.length === 0 ? (_(), x("div", Be, " 暂无事件记录 ")) : D("", !0)
], 2)
])
]));
}
}), vl = /* @__PURE__ */ q(Ne, [["__scopeId", "data-v-3f45f002"]]), Ke = { class: "marker-panel" }, Je = { class: "panel-header" }, je = { class: "panel-stats" }, Ye = { class: "panel-actions" }, Ge = ["disabled"], Xe = ["disabled"], qe = {
key: 0,
class: "add-form"
}, Qe = { class: "form-group" }, ot = { class: "form-group" }, et = { class: "form-row" }, tt = { class: "form-group" }, nt = { class: "form-group" }, lt = { class: "form-row" }, st = { class: "form-group" }, it = { class: "form-group" }, at = { class: "form-options" }, rt = { class: "checkbox-label" }, ut = { class: "select-group" }, dt = { class: "marker-list" }, ct = {
key: 0,
class: "empty-state"
}, vt = {
key: 1,
class: "marker-items"
}, pt = ["onClick"], mt = { class: "marker-info" }, ft = { class: "marker-title" }, gt = { class: "marker-position" }, bt = {
key: 0,
class: "marker-content"
}, yt = { class: "marker-actions" }, kt = ["onClick", "title"], Ct = ["onClick"], wt = ["onClick"], $t = {
key: 1,
class: "edit-modal"
}, Mt = { class: "modal-content" }, ht = { class: "modal-body" }, It = { class: "form-group" }, xt = { class: "form-group" }, _t = { class: "form-row" }, Wt = { class: "form-group" }, Tt = { class: "form-group" }, zt = { class: "form-options" }, Et = { class: "checkbox-label" }, Ut = { class: "checkbox-label" }, Lt = /* @__PURE__ */ X({
__name: "MarkerPanel",
props: {
markers: {},
selectedMarker: {},
markerCount: {},
visibleMarkerCount: {},
mapCenter: {}
},
emits: ["add-marker", "remove-marker", "update-marker", "select-marker", "toggle-visibility", "clear-markers", "fit-to-view"],
setup(w, { emit: t }) {
const g = w, i = t, p = U(!1), M = U(null), f = U({
title: "",
content: "",
position: { lat: 0, lng: 0 },
iconUrl: "",
labelText: "",
draggable: !1,
animation: ""
}), C = U({}), l = () => {
f.value = {
title: "",
content: "",
position: { lat: g.mapCenter?.lat || 0, lng: g.mapCenter?.lng || 0 },
iconUrl: "",
labelText: "",
draggable: !1,
animation: ""
};
}, W = () => {
const L = {
title: f.value.title || void 0,
content: f.value.content || void 0,
position: f.value.position,
draggable: f.value.draggable,
animation: f.value.animation || null
};
f.value.iconUrl && (L.icon = f.value.iconUrl), f.value.labelText && (L.label = f.value.labelText), i("add-marker", L), l(), p.value = !1;
}, I = () => {
g.mapCenter && (f.value.position = { ...g.mapCenter }, W());
}, T = (L) => {
confirm("确定要删除这个标记吗?") && i("remove-marker", L);
}, z = () => {
confirm("确定要清空所有标记吗?") && i("clear-markers");
}, m = (L) => {
i("toggle-visibility", L);
}, n = (L) => {
i("select-marker", L);
}, y = () => {
i("fit-to-view");
}, A = (L) => {
M.value = L, C.value = { ...L };
}, S = () => {
M.value && C.value && (i("update-marker", M.value.id, C.value), V());
}, V = () => {
M.value = null, C.value = {};
};
return l(), (L, c) => (_(), x("div", Ke, [
o("div", Je, [
c[15] || (c[15] = o("h3", null, "标记管理", -1)),
o("div", je, [
o("span", null, "总数: " + h(L.markerCount), 1),
o("span", null, "可见: " + h(L.visibleMarkerCount), 1)
])
]),
o("div", Ye, [
o("button", {
onClick: c[0] || (c[0] = (d) => p.value = !p.value),
class: "action-btn primary"
}, h(p.value ? "取消添加" : "添加标记"), 1),
o("button", {
onClick: z,
class: "action-btn danger",
disabled: L.markerCount === 0
}, " 清空所有 ", 8, Ge),
o("button", {
onClick: y,
class: "action-btn secondary",
disabled: L.visibleMarkerCount === 0
}, " 适应视图 ", 8, Xe)
]),
p.value ? (_(), x("div", qe, [
c[25] || (c[25] = o("h4", null, "添加新标记", -1)),
o("div", Qe, [
c[16] || (c[16] = o("label", null, "标题:", -1)),
$(o("input", {
"onUpdate:modelValue": c[1] || (c[1] = (d) => f.value.title = d),
type: "text",
placeholder: "标记标题"
}, null, 512), [
[O, f.value.title]
])
]),
o("div", ot, [
c[17] || (c[17] = o("label", null, "描述:", -1)),
$(o("textarea", {
"onUpdate:modelValue": c[2] || (c[2] = (d) => f.value.content = d),
placeholder: "标记描述"
}, null, 512), [
[O, f.value.content]
])
]),
o("div", et, [
o("div", tt, [
c[18] || (c[18] = o("label", null, "纬度:", -1)),
$(o("input", {
"onUpdate:modelValue": c[3] || (c[3] = (d) => f.value.position.lat = d),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
f.value.position.lat,
void 0,
{ number: !0 }
]
])
]),
o("div", nt, [
c[19] || (c[19] = o("label", null, "经度:", -1)),
$(o("input", {
"onUpdate:modelValue": c[4] || (c[4] = (d) => f.value.position.lng = d),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
f.value.position.lng,
void 0,
{ number: !0 }
]
])
])
]),
o("div", lt, [
o("div", st, [
c[20] || (c[20] = o("label", null, "图标URL:", -1)),
$(o("input", {
"onUpdate:modelValue": c[5] || (c[5] = (d) => f.value.iconUrl = d),
type: "text",
placeholder: "图标地址(可选)"
}, null, 512), [
[O, f.value.iconUrl]
])
]),
o("div", it, [
c[21] || (c[21] = o("label", null, "标签文本:", -1)),
$(o("input", {
"onUpdate:modelValue": c[6] || (c[6] = (d) => f.value.labelText = d),
type: "text",
placeholder: "标签文本(可选)"
}, null, 512), [
[O, f.value.labelText]
])
])
]),
o("div", at, [
o("label", rt, [
$(o("input", {
"onUpdate:modelValue": c[7] || (c[7] = (d) => f.value.draggable = d),
type: "checkbox"
}, null, 512), [
[F, f.value.draggable]
]),
c[22] || (c[22] = o("span", null, "可拖拽", -1))
]),
o("div", ut, [
c[24] || (c[24] = o("label", null, "动画:", -1)),
$(o("select", {
"onUpdate:modelValue": c[8] || (c[8] = (d) => f.value.animation = d)
}, c[23] || (c[23] = [
o("option", { value: "" }, "无动画", -1),
o("option", { value: "DROP" }, "下落", -1),
o("option", { value: "BOUNCE" }, "弹跳", -1)
]), 512), [
[N, f.value.animation]
])
])
]),
o("div", { class: "form-actions" }, [
o("button", {
onClick: W,
class: "action-btn primary"
}, "添加"),
o("button", {
onClick: I,
class: "action-btn secondary"
}, "在中心添加")
])
])) : D("", !0),
o("div", dt, [
c[26] || (c[26] = o("h4", null, "标记列表", -1)),
L.markers.length === 0 ? (_(), x("div", ct, " 暂无标记 ")) : (_(), x("div", vt, [
(_(!0), x(K, null, J(L.markers, (d) => (_(), x("div", {
key: d.id,
class: G(["marker-item", {
selected: L.selectedMarker?.id === d.id,
hidden: d.visible === !1
}]),
onClick: (v) => n(d.id)
}, [
o("div", mt, [
o("div", ft, h(d.title || `标记 ${d.id.slice(-6)}`), 1),
o("div", gt, h(d.position.lat.toFixed(6)) + ", " + h(d.position.lng.toFixed(6)), 1),
d.content ? (_(), x("div", bt, h(d.content), 1)) : D("", !0)
]),
o("div", yt, [
o("button", {
onClick: Q((v) => m(d.id), ["stop"]),
class: "icon-btn",
title: d.visible === !1 ? "显示" : "隐藏"
}, h(d.visible === !1 ? "👁️" : "🙈"), 9, kt),
o("button", {
onClick: Q((v) => A(d), ["stop"]),
class: "icon-btn",
title: "编辑"
}, " ✏️ ", 8, Ct),
o("button", {
onClick: Q((v) => T(d.id), ["stop"]),
class: "icon-btn danger",
title: "删除"
}, " 🗑️ ", 8, wt)
])
], 10, pt))), 128))
]))
]),
M.value ? (_(), x("div", $t, [
o("div", Mt, [
o("div", { class: "modal-header" }, [
c[27] || (c[27] = o("h4", null, "编辑标记", -1)),
o("button", {
onClick: V,
class: "close-btn"
}, "×")
]),
o("div", ht, [
o("div", It, [
c[28] || (c[28] = o("label", null, "标题:", -1)),
$(o("input", {
"onUpdate:modelValue": c[9] || (c[9] = (d) => C.value.title = d),
type: "text"
}, null, 512), [
[O, C.value.title]
])
]),
o("div", xt, [
c[29] || (c[29] = o("label", null, "描述:", -1)),
$(o("textarea", {
"onUpdate:modelValue": c[10] || (c[10] = (d) => C.value.content = d)
}, null, 512), [
[O, C.value.content]
])
]),
o("div", _t, [
o("div", Wt, [
c[30] || (c[30] = o("label", null, "纬度:", -1)),
$(o("input", {
"onUpdate:modelValue": c[11] || (c[11] = (d) => C.value.position.lat = d),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
C.value.position.lat,
void 0,
{ number: !0 }
]
])
]),
o("div", Tt, [
c[31] || (c[31] = o("label", null, "经度:", -1)),
$(o("input", {
"onUpdate:modelValue": c[12] || (c[12] = (d) => C.value.position.lng = d),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
C.value.position.lng,
void 0,
{ number: !0 }
]
])
])
]),
o("div", zt, [
o("label", Et, [
$(o("input", {
"onUpdate:modelValue": c[13] || (c[13] = (d) => C.value.draggable = d),
type: "checkbox"
}, null, 512), [
[F, C.value.draggable]
]),
c[32] || (c[32] = o("span", null, "可拖拽", -1))
]),
o("label", Ut, [
$(o("input", {
"onUpdate:modelValue": c[14] || (c[14] = (d) => C.value.visible = d),
type: "checkbox"
}, null, 512), [
[F, C.value.visible]
]),
c[33] || (c[33] = o("span", null, "可见", -1))
])
])
]),
o("div", { class: "modal-actions" }, [
o("button", {
onClick: S,
class: "action-btn primary"
}, "保存"),
o("button", {
onClick: V,
class: "action-btn secondary"
}, "取消")
])
])
])) : D("", !0)
]));
}
}), pl = /* @__PURE__ */ q(Lt, [["__scopeId", "data-v-be51a63c"]]), St = { class: "infowindow-panel" }, Vt = { class: "panel-header" }, Zt = { class: "panel-stats" }, Ot = { key: 0 }, Pt = { class: "panel-actions" }, At = ["disabled"], Rt = ["disabled"], Ft = {
key: 0,
class: "add-form"
}, Dt = { class: "form-group" }, Ht = { class: "form-group" }, Bt = { class: "form-row" }, Nt = { class: "form-group" }, Kt = { class: "form-group" }, Jt = { class: "form-row" }, jt = { class: "form-group" }, Yt = { class: "form-group" }, Gt = { class: "form-options" }, Xt = { class: "checkbox-label" }, qt = { class: "select-group" }, Qt = ["value"], on = { class: "infowindow-list" }, en = {
key: 0,
class: "empty-state"
}, tn = {
key: 1,
class: "infowindow-items"
}, nn = ["onClick"], ln = { class: "infowindow-info" }, sn = { class: "infowindow-title" }, an = { class: "infowindow-position" }, rn = { class: "infowindow-content" }, un = {
key: 0,
class: "infowindow-marker"
}, dn = { class: "infowindow-actions" }, cn = ["onClick", "title"], vn = ["onClick"], pn = ["onClick"], mn = {
key: 1,
class: "edit-modal"
}, fn = { class: "modal-content" }, gn = { class: "modal-body" }, bn = { class: "form-group" }, yn = { class: "form-group" }, kn = { class: "form-row" }, Cn = { class: "form-group" }, wn = { class: "form-group" }, $n = { class: "form-options" }, Mn = { class: "checkbox-label" }, hn = { class: "checkbox-label" }, In = /* @__PURE__ */ X({
__name: "InfoWindowPanel",
props: {
infoWindows: {},
activeInfoWindow: {},
infoWindowCount: {},
visibleInfoWindowCount: {},
markers: {},
mapCenter: {}
},
emits: ["add-infowindow", "remove-infowindow", "update-infowindow", "open-infowindow", "close-infowindow", "close-all-infowindows", "clear-infowindows", "toggle-infowindow"],
setup(w, { emit: t }) {
const g = w, i = t, p = U(!1), M = U(null), f = U({
title: "",
content: "",
position: { lat: 0, lng: 0 },
offset: [0, 0],
closable: !0,
markerId: ""
}), C = U({}), l = () => {
f.value = {
title: "",
content: "",
position: { lat: g.mapCenter?.lat || 0, lng: g.mapCenter?.lng || 0 },
offset: [0, 0],
closable: !0,
markerId: ""
};
}, W = () => {
const d = {
title: f.value.title || void 0,
content: f.value.content,
position: f.value.position,
offset: f.value.offset,
closable: f.value.closable,
markerId: f.value.markerId || void 0
};
i("add-infowindow", d), l(), p.value = !1;
}, I = () => {
g.mapCenter && (f.value.position = { ...g.mapCenter }, W());
}, T = (d) => {
confirm("确定要删除这个信息窗吗?") && i("remove-infowindow", d);
}, z = () => {
confirm("确定要清空所有信息窗吗?") && i("clear-infowindows");
}, m = () => {
i("close-all-infowindows");
}, n = (d) => {
i("toggle-infowindow", d);
}, y = (d) => {
d.visible === !1 && i("open-infowindow", d.id);
}, A = (d) => {
M.value = d, C.value = { ...d };
}, S = () => {
M.value && C.value && (i("update-infowindow", M.value.id, C.value), V());
}, V = () => {
M.value = null, C.value = {};
}, L = (d) => typeof d == "string" ? d.length > 50 ? d.substring(0, 50) + "..." : d : "[HTML内容]", c = (d) => g.markers.find((k) => k.id === d)?.title || `标记 ${d.slice(-6)}`;
return l(), (d, v) => (_(), x("div", St, [
o("div", Vt, [
v[15] || (v[15] = o("h3", null, "信息窗管理", -1)),
o("div", Zt, [
o("span", null, "总数: " + h(d.infoWindowCount), 1),
o("span", null, "可见: " + h(d.visibleInfoWindowCount), 1),
d.activeInfoWindow ? (_(), x("span", Ot, "活动: " + h(d.activeInfoWindow.title || d.activeInfoWindow.id.slice(-6)), 1)) : D("", !0)
])
]),
o("div", Pt, [
o("button", {
onClick: v[0] || (v[0] = (k) => p.value = !p.value),
class: "action-btn primary"
}, h(p.value ? "取消添加" : "添加信息窗"), 1),
o("button", {
onClick: m,
class: "action-btn secondary",
disabled: d.visibleInfoWindowCount === 0
}, " 关闭所有 ", 8, At),
o("button", {
onClick: z,
class: "action-btn danger",
disabled: d.infoWindowCount === 0
}, " 清空所有 ", 8, Rt)
]),
p.value ? (_(), x("div", Ft, [
v[25] || (v[25] = o("h4", null, "添加新信息窗", -1)),
o("div", Dt, [
v[16] || (v[16] = o("label", null, "标题:", -1)),
$(o("input", {
"onUpdate:modelValue": v[1] || (v[1] = (k) => f.value.title = k),
type: "text",
placeholder: "信息窗标题"
}, null, 512), [
[O, f.value.title]
])
]),
o("div", Ht, [
v[17] || (v[17] = o("label", null, "内容:", -1)),
$(o("textarea", {
"onUpdate:modelValue": v[2] || (v[2] = (k) => f.value.content = k),
placeholder: "信息窗内容",
rows: "3"
}, null, 512), [
[O, f.value.content]
])
]),
o("div", Bt, [
o("div", Nt, [
v[18] || (v[18] = o("label", null, "纬度:", -1)),
$(o("input", {
"onUpdate:modelValue": v[3] || (v[3] = (k) => f.value.position.lat = k),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
f.value.position.lat,
void 0,
{ number: !0 }
]
])
]),
o("div", Kt, [
v[19] || (v[19] = o("label", null, "经度:", -1)),
$(o("input", {
"onUpdate:modelValue": v[4] || (v[4] = (k) => f.value.position.lng = k),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
f.value.position.lng,
void 0,
{ number: !0 }
]
])
])
]),
o("div", Jt, [
o("div", jt, [
v[20] || (v[20] = o("label", null, "X偏移:", -1)),
$(o("input", {
"onUpdate:modelValue": v[5] || (v[5] = (k) => f.value.offset[0] = k),
type: "number"
}, null, 512), [
[
O,
f.value.offset[0],
void 0,
{ number: !0 }
]
])
]),
o("div", Yt, [
v[21] || (v[21] = o("label", null, "Y偏移:", -1)),
$(o("input", {
"onUpdate:modelValue": v[6] || (v[6] = (k) => f.value.offset[1] = k),
type: "number"
}, null, 512), [
[
O,
f.value.offset[1],
void 0,
{ number: !0 }
]
])
])
]),
o("div", Gt, [
o("label", Xt, [
$(o("input", {
"onUpdate:modelValue": v[7] || (v[7] = (k) => f.value.closable = k),
type: "checkbox"
}, null, 512), [
[F, f.value.closable]
]),
v[22] || (v[22] = o("span", null, "可关闭", -1))
]),
o("div", qt, [
v[24] || (v[24] = o("label", null, "关联标记:", -1)),
$(o("select", {
"onUpdate:modelValue": v[8] || (v[8] = (k) => f.value.markerId = k)
}, [
v[23] || (v[23] = o("option", { value: "" }, "无关联", -1)),
(_(!0), x(K, null, J(d.markers, (k) => (_(), x("option", {
key: k.id,
value: k.id
}, h(k.title || `标记 ${k.id.slice(-6)}`), 9, Qt))), 128))
], 512), [
[N, f.value.markerId]
])
])
]),
o("div", { class: "form-actions" }, [
o("button", {
onClick: W,
class: "action-btn primary"
}, "添加"),
o("button", {
onClick: I,
class: "action-btn secondary"
}, "在中心添加")
])
])) : D("", !0),
o("div", on, [
v[26] || (v[26] = o("h4", null, "信息窗列表", -1)),
d.infoWindows.length === 0 ? (_(), x("div", en, " 暂无信息窗 ")) : (_(), x("div", tn, [
(_(!0), x(K, null, J(d.infoWindows, (k) => (_(), x("div", {
key: k.id,
class: G(["infowindow-item", {
active: d.activeInfoWindow?.id === k.id,
hidden: k.visible === !1
}]),
onClick: (H) => y(k)
}, [
o("div", ln, [
o("div", sn, h(k.title || `信息窗 ${k.id.slice(-6)}`), 1),
o("div", an, h(k.position.lat.toFixed(6)) + ", " + h(k.position.lng.toFixed(6)), 1),
o("div", rn, h(L(k.content)), 1),
k.markerId ? (_(), x("div", un, " 关联标记: " + h(c(k.markerId)), 1)) : D("", !0)
]),
o("div", dn, [
o("button", {
onClick: Q((H) => n(k.id), ["stop"]),
class: "icon-btn",
title: k.visible === !1 ? "显示" : "隐藏"
}, h(k.visible === !1 ? "👁️" : "🙈"), 9, cn),
o("button", {
onClick: Q((H) => A(k), ["stop"]),
class: "icon-btn",
title: "编辑"
}, " ✏️ ", 8, vn),
o("button", {
onClick: Q((H) => T(k.id), ["stop"]),
class: "icon-btn danger",
title: "删除"
}, " 🗑️ ", 8, pn)
])
], 10, nn))), 128))
]))
]),
M.value ? (_(), x("div", mn, [
o("div", fn, [
o("div", { class: "modal-header" }, [
v[27] || (v[27] = o("h4", null, "编辑信息窗", -1)),
o("button", {
onClick: V,
class: "close-btn"
}, "×")
]),
o("div", gn, [
o("div", bn, [
v[28] || (v[28] = o("label", null, "标题:", -1)),
$(o("input", {
"onUpdate:modelValue": v[9] || (v[9] = (k) => C.value.title = k),
type: "text"
}, null, 512), [
[O, C.value.title]
])
]),
o("div", yn, [
v[29] || (v[29] = o("label", null, "内容:", -1)),
$(o("textarea", {
"onUpdate:modelValue": v[10] || (v[10] = (k) => C.value.content = k),
rows: "4"
}, null, 512), [
[O, C.value.content]
])
]),
o("div", kn, [
o("div", Cn, [
v[30] || (v[30] = o("label", null, "纬度:", -1)),
$(o("input", {
"onUpdate:modelValue": v[11] || (v[11] = (k) => C.value.position.lat = k),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
C.value.position.lat,
void 0,
{ number: !0 }
]
])
]),
o("div", wn, [
v[31] || (v[31] = o("label", null, "经度:", -1)),
$(o("input", {
"onUpdate:modelValue": v[12] || (v[12] = (k) => C.value.position.lng = k),
type: "number",
step: "0.000001"
}, null, 512), [
[
O,
C.value.position.lng,
void 0,
{ number: !0 }
]
])
])
]),
o("div", $n, [
o("label", Mn, [
$(o("input", {
"onUpdate:modelValue": v[13] || (v[13] = (k) => C.value.closable = k),
type: "checkbox"
}, null, 512), [
[F, C.value.closable]
]),
v[32] || (v[32] = o("span", null, "可关闭", -1))
]),
o("label", hn, [
$(o("input", {
"onUpdate:modelValue": v[14] || (v[14] = (k) => C.value.visible = k),
type: "checkbox"
}, null, 512), [
[F, C.value.visible]
]),
v[33] || (v[33] = o("span", null, "可见", -1))
])
])
]),
o("div", { class: "modal-actions" }, [
o("button", {
onClick: S,
class: "action-btn primary"
}, "保存"),
o("button", {
onClick: V,
class: "action-btn secondary"
}, "取消")
])
])
])) : D("", !0)
]));
}
}), ml = /* @__PURE__ */ q(In, [["__scopeId", "data-v-63115bb4"]]), xn = { class: "basic-example" }, _n = { class: "example-container" }, Wn = { class: "info-panel" }, Tn = { class: "log-container" }, zn = { class: "log-time" }, En = { class: "log-message" }, Un = /* @__PURE__ */ X({
__name: "BasicExample",
setup(w) {
const t = U(), g = U([]), i = (I) => {
const T = (/* @__PURE__ */ new Date()).toLocaleTimeString();
g.value.unshift({ time: T, message: I }), g.value.length > 20 && (g.value = g.value.slice(0, 20));
}, p = (I) => {
i("地图加载完成"), console.log("地图实例:", I);
}, M = (I) => {
const T = I.coordinate[0], z = I.coordinate[1];
i(`地图点击: ${z.toFixed(6)}, ${T.toFixed(6)}`);
}, f = () => {
if (!t.value) return;
const I = 39.9042 + (Math.random() - 0.5) * 0.1, T = 116.4074 + (Math.random() - 0.5) * 0.1, z = t.value.addMarker({
position: { lat: I, lng: T },
title: `随机标记 ${Date.now()}`,
content: `这是一个随机生成的标记,位置: ${I.toFixed(6)}, ${T.toFixed(6)}`,
draggable: !0,
animation: Math.random() > 0.5 ? "DROP" : "BOUNCE"
});
i(`添加标记: ${z}`);
}, C = () => {
if (!t.value) return;
const I = 39.9042 + (Math.random() - 0.5) * 0.05, T = 116.4074 + (Math.random() - 0.5) * 0.05, z = t.value.addInfoWindow({
position: { lat: I, lng: T },
content: `
<div style="padding: 10px; max-width: 200px;">
<h4 style="margin: 0 0 8px 0; color: #333;">信息窗示例</h4>
<p style="margin: 0; font-size: 14px; color: #666;">
这是一个信息窗示例,位置: ${I.toFixed(4)}, ${T.toFixed(4)}
</p>
<p style="margin: 8px 0 0 0; font-size: 12px; color: #999;">
点击时间: ${(/* @__PURE__ */ new Date()).toLocaleString()}
</p>
</div>
`,
closable: !0
});
t.value.openInfoWindow(z), i(`添加信息窗: ${z}`);
}, l = () => {
if (!t.value) return;
const I = t.value.clearMarkers(), T = t.value.clearInfoWindows();
i(`清空 ${I} 个标记和 ${T} 个信息窗`);
}, W = () => {
if (!t.value) return;
const I = t.value.fitMarkersToView();
i(I ? "已适应所有标记到视图" : "没有可见的标记");
};
return (I, T) => (_(), x("div", xn, [
T[2] || (T[2] = o("h2", null, "基础地图示例", -1)),
T[3] || (T[3] = o("p", null, "这是一个简单的华为地图组件使用示例", -1)),
o("div", _n, [
vo(po, {
ref_key: "mapRef",
ref: t,
center: { lat: 39.9042, lng: 116.4074 },
zoom: 10,
width: "100%",
height: "400px",
"zoom-control": !0,
"scale-control": !0,
"location-control": !0,
onMapReady: p,
onMapClick: M
}, null, 512)
]),
o("div", { class: "controls" }, [
T[0] || (T[0] = o("h3", null, "地图控制", -1)),
o("div", { class: "control-buttons" }, [
o("button", {
onClick: f,
class: "btn primary"
}, "添加随机标记"),
o("button", {
onClick: C,
class: "btn secondary"
}, "添加信息窗"),
o("button", {
onClick: l,
class: "btn danger"
}, "清空所有"),
o("button", {
onClick: W,
class: "btn info"
}, "适应视图")
])
]),
o("div", Wn, [
T[1] || (T[1] = o("h3", null, "操作日志", -1)),
o("div", Tn, [
(_(!0), x(K, null, J(g.value, (z, m) => (_(), x("div", {
key: m,
class: "log-item"
}, [
o("span", zn, h(z.time), 1),
o("span", En, h(z.message), 1)
]))), 128))
])
])
]));
}
}), fl = /* @__PURE__ */ q(Un, [["__scopeId", "data-v-234a828f"]]), Ln = { class: "advanced-example" }, Sn = { class: "example-layout" }, Vn = { class: "map-container" }, Zn = { class: "control-panel" }, On = { class: "section" }, Pn = { class: "form-group" }, An = { class: "form-group" }, Rn = { class: "form-group" }, Fn = { class: "section" }, Dn = { class: "preset-buttons" }, Hn = ["onClick"], Bn = { class: "section" }, Nn = { class: "stats" }, Kn = { class: "stat-item" }, Jn = { class: "stat-value" }, jn = { class: "stat-item" }, Yn = { class: "stat-value" }, Gn = { class: "stat-item" }, Xn = { class: "stat-value" }, qn = { class: "stat-item" }, Qn = { class: "stat-value" }, ol = { class: "event-log" }, el = { class: "log-controls" }, tl = { class: "checkbox-label" }, nl = { class: "log-time" }, ll = { class: "log-type" }, sl = { class: "log-message" }, il = /* @__PURE__ */ X({
__name: "AdvancedExample",
setup(w) {
const t = U(), g = U(), i = U({ lat: 39.9042, lng: 116.4074 }), p = U(10), M = U("zh"), f = U("raster"), C = U("ROADMAP"), l = U(!0), W = U([]), I = [
{ name: "北京", lat: 39.9042, lng: 116.4074 },
{ name: "上海", lat: 31.2304, lng: 121.4737 },
{ name: "广州", lat: 23.1291, lng: 113.2644 },
{ name: "深圳", lat: 22.5431, lng: 114.0579 },
{ name: "杭州", lat: 30.2741, lng: 120.1551 },
{ name: "南京", lat: 32.0603, lng: 118.7969 }
], T = B(() => t.value?.markerCount || 0), z = B(() => t.value?.infoWindowCount || 0), m = (a, e) => {
const r = (/* @__PURE__ */ new Date()).toLocaleTimeString();
W.value.unshift({ time: r, type: a, message: e }), W.value.length > 100 && (W.value = W.value.slice(0, 100)), l.value && eo(() => {
g.value && (g.value.scrollTop = 0);
});
}, n = (a) => `${a.lat.toFixed(4)}, ${a.lng.toFixed(4)}`, y = (a) => {
m("system", "地图加载完成");
}, A = (a) => {
const e = a.coordinate[0], r = a.coordinate[1];
m("click", `地图点击: ${r.toFixed(6)}, ${e.toFixed(6)}`);
}, S = (a, e) => {
m("marker", `标记点击: ${a.title || a.id}`);
}, V = (a) => {
i.value = a, m("change", `中心点变化: ${n(a)}`);
}, L = (a) => {
p.value = a, m("change", `缩放级别变化: ${a}`);
}, c = (a) => {
i.value = { lat: a.lat, lng: a.lng }, m("action", `跳转到${a.name}`);
}, d = () => {
if (!t.value) return;
const a = [
{ lat: 39.9042, lng: 116.4074, title: "天安门", content: "中华人民共和国的象征" },
{ lat: 39.9163, lng: 116.3972, title: "故宫", content: "明清两朝的皇家宫殿" },
{ lat: 39.8844, lng: 116.4056, title: "天坛", content: "明清皇帝祭天的场所" },
{ lat: 40.0031, lng: 116.3272, title: "颐和园", content: "中国古典园林的杰作" },
{ lat: 40.3598, lng: 116.0203, title: "八达岭长城", content: "万里长城的精华段" }
];
a.forEach((e) => {
const r = t.value.addMarker({
position: { lat: e.lat, lng: e.lng },
title: e.title,
content: e.content,
draggable: !0
});
t.value.createInfoWindowForMarker(
r,
{ lat: e.lat, lng: e.lng },
`<div style="padding: 10px;">
<h4 style="margin: 0 0 8px 0;">${e.title}</h4>
<p style="margin: 0; font-size: 14px;">${e.content}</p>
</div>`
);
}), m("action", `添加了${a.length}个标记`);
}, v = () => {
if (!t.value) return;
const a = [];
for (let e = 0; e < 10; e++) {
const r = i.value.lat + (Math.random() - 0.5) * 0.02, u = i.value.lng + (Math.random() - 0.5) * 0.02;
a.push({
position: { lat: r, lng: u },
title: `集群标记 ${e + 1}`,
content: `这是集群中的第${e + 1}个标记`,
draggable: !1
});
}
t.value.addMarkers(a), m("action", `创建了包含${a.length}个标记的集群`);
}, k = () => {
if (!t.value) return;
const a = t.value.markers || [];
let e = 0;
a.forEach((r) => {
try {
t.value.showMarkerInfoWindow(r.id), e++;
} catch {
}
}), m("action", `显示了${e}个信息窗`);
}, H = () => {
if (!t.value) return;
const a = t.value.clearMarkers(), e = t.value.clearInfoWindows();
m("action", `清空了${a}个标记和${e}个信息窗`);
}, b = () => {
W.value = [], m("system", "日志已清空");
};
return P([C, f, M], () => {
m("config", "地图配置已更新");
}), (a, e) => (_(), x("div", Ln, [
e[20] || (e[20] = o("h2", null, "高级地图示例", -1)),
e[21] || (e[21] = o("p", null, "展示华为地图组件的高级功能,包括事件监控、标记管理和信息窗", -1)),
o("div", Sn, [
o("div", Vn, [
vo(po, {
ref_key: "mapRef",
ref: t,
center: i.value,
zoom: p.value,
language: M.value,
"source-type": f.value,
"map-type": C.value,
"zoom-control": !0,
"scale-control": !0,
"location-control": !0,
"enable-event-monitor": !0,
width: "100%",
height: "500px",
onMapReady: y,
onMapClick: A,
onMarkerClick: S,
onCenterChanged: V,
onZoomChanged: L
}, null, 8, ["center", "zoom", "language", "source-type", "map-type"])
]),
o("div", Zn, [
o("div", On, [
e[10] || (e[10] = o("h3", null, "地图设置", -1)),
o("div", Pn, [
e[5] || (e[5] = o("label", null, "地图类型:", -1)),
$(o("select", {
"onUpdate:modelValue": e[0] || (e[0] = (r) => C.value = r)
}, e[4] || (e[4] = [
o("option", { value: "ROADMAP" }, "基础地图", -1),
o("option", { value: "TERRAIN" }, "地形图", -1)
]), 512), [
[N, C.value]
])
]),
o("div", An, [
e[7] || (e[7] = o("label", null, "瓦片类型:", -1)),
$(o("select", {
"onUpdate:modelValue": e[1] || (e[1] = (r) => f.value = r)
}, e[6] || (e[6] = [
o("option", { value: "vector" }, "矢量", -1),
o("option", { value: "raster" }, "栅格", -1)
]), 512), [
[N, f.value]
])
]),
o("div", Rn, [
e[9] || (e[9] = o("label", null, "语言:", -1)),
$(o("select", {
"onUpdate:modelValue": e[2] || (e[2] = (r) => M.value = r)
}, e[8] || (e[8] = [
o("option", { value: "zh" }, "中文", -1),
o("option", { value: "en" }, "English", -1)
]), 512), [
[N, M.value]
])
])
]),
o("div", Fn, [
e[11] || (e[11] = o("h3", null, "预设位置", -1)),
o("div", Dn, [
(_(), x(K, null, J(I, (r) => o("button", {
key: r.name,
onClick: (u) => c(r),
class: "preset-btn"
}, h(r.name), 9, Hn)), 64))
])
]),
o("div", { class: "section" }, [
e[12] || (e[12] = o("h3", null, "批量操作", -1)),
o("div", { class: "batch-buttons" }, [
o("button", {
onClick: d,
class: "btn primary"
}, "添加多个标记"),
o("button", {
onClick: v,
class: "btn secondary"
}, "创建标记集群"),
o("button", {
onClick: k,
class: "btn info"
}, "显示所有信息窗"),
o("button", {
onClick: H,
class: "btn danger"
}, "清空所有")
])
]),
o("div", Bn, [
e[17] || (e[17] = o("h3", null, "统计信息", -1)),
o("div", Nn, [
o("div", Kn, [
e[13] || (e[13] = o("span", { class: "stat-label" }, "标记数量:", -1)),
o("span", Jn, h(T.value), 1)
]),
o("div", jn, [
e[14] || (e[14] = o("span", { class: "stat-label" }, "信息窗数量:", -1)),
o("span", Yn, h(z.value), 1)
]),
o("div", Gn, [
e[15] || (e[15] = o("span", { class: "stat-label" }, "当前中心:", -1)),
o("span", Xn, h(n(i.value)), 1)
]),
o("div", qn, [
e[16] || (e[16] = o("span", { class: "stat-label" }, "当前缩放:", -1)),
o("span", Qn, h(p.value), 1)
])
])
])
])
]),
o("div", ol, [
e[19] || (e[19] = o("h3", null, "事件日志", -1)),
o("div", el, [
o("button", {
onClick: b,
class: "btn small"
}, "清空日志"),
o("label", tl, [
$(o("input", {
"onUpdate:modelValue": e[3] || (e[3] = (r) => l.value = r),
type: "checkbox"
}, null, 512), [
[F, l.value]
]),
e[18] || (e[18] = o("span", null, "自动滚动", -1))
])
]),
o("div", {
ref_key: "logContainer",
ref: g,
class: G(["log-container", { "auto-scroll": l.value }])
}, [
(_(!0), x(K, null, J(W.value, (r, u) => (_(), x("div", {
key: u,
class: G(["log-entry", `log-${r.type}`])
}, [
o("span", nl, h(r.time), 1),
o("span", ll, h(r.type), 1),
o("span", sl, h(r.message), 1)
], 2))), 128))
], 2)
])
]));
}
}), gl = /* @__PURE__ */ q(il, [["__scopeId", "data-v-c75a8372"]]), bl = "1.0.0";
export {
gl as AdvancedExample,
fl as BasicExample,
po as HuaweiMap,
ml as InfoWindowPanel,
cl as MapConfigPanel,
vl as MapEventMonitor,
pl as MarkerPanel,
R as defaultMapConfig,
dl as isHuaweiMapAPILoaded,
Ao as loadHuaweiMapAPI,
rl as mapStyles,
ul as mapTypes,
Do as useInfoWindows,
Ko as useMapConfig,
Ro as useMapEvents,
Fo as useMapMarkers,
bl as version
};