UNPKG

vue-tianditu2

Version:
112 lines (111 loc) 3.29 kB
import { defineComponent as l, onBeforeMount as u, h as e } from "vue"; import { useMapRoot as m } from "../../use/mapRoot.mjs"; import { fixMapPropagation as h } from "../../utils/fix.mjs"; import { useMethods as d } from "./use/methods.mjs"; import { useState as g } from "./use/state.mjs"; import { SearchBox as f } from "./components/SearchBox.mjs"; import { SearchSuggests as S } from "./components/SearchSuggests.mjs"; import { SearchPois as C } from "./components/SearchPois.mjs"; import { SearchMapView as k } from "./components/SearchMapView.mjs"; import { IconClose as w, IconSearch as B, IconRoute as M } from "./components/icons.mjs"; import { TdtRoute as y } from "../route/index.mjs"; /* empty css */ /* empty css */ const A = l({ name: "TdtSearch", props: { placeholder: { type: String, default: "输入关键字搜索" }, searchBtn: { type: Boolean, default: !0 }, routeBtn: { type: Boolean, default: !0 } }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars "poi-click": (o) => !0, // eslint-disable-next-line @typescript-eslint/no-unused-vars "suggest-click": (o) => !0, // eslint-disable-next-line @typescript-eslint/no-unused-vars "search-complete": (o) => !0 }, setup(o, { emit: s }) { const t = g(), { onSearchComplete: n, onPoiClick: c, onSuggestClick: p, onSearch: a, onPageChange: i } = d(t, s); return u(async () => { t.tdtMap = await m(), t.localSearch = new T.LocalSearch(t.tdtMap, { pageCapacity: 10, onSearchComplete: n }); }), () => e( "div", { class: "tdt-search", // 解决地图的滚动冒泡和点击及双击冒泡 ...h(t.tdtMap) }, t.showRoute ? [ e(y), e( "i", { class: "tdt-search-route__close", onClick: () => t.showRoute = !1 }, [e(w)] ) ] : [ e( f, { modelValue: t.keyword, placeholder: o.placeholder, "onUpdate:modelValue": (r) => { t.keyword = r, a(4, r); }, onSearch: (r) => a(1, r) }, [ o.searchBtn && e( "button", { class: "tdt-search-box__btn", onClick: () => a(1) }, [e(B)] ), o.routeBtn && e( "button", { class: "tdt-search-box__btn", onClick: () => t.showRoute = !0 }, [e(M)] ) ] ), e(S, { suggests: t.suggests || [], onSuggestClick: p }), e(C, { pois: t.pois || [], page: { current: t.current, size: 10, total: t.total }, onPoiClick: c, "onUpdate:page": i }), e(k, { pois: t.pois || [], target: t.target, content: t.content, onPoiClick: c, "onUpdate:target": (r) => t.target = r }) ] ); } }); export { A as TdtSearch }; //# sourceMappingURL=index.mjs.map