|
@@ -5,9 +5,19 @@
|
|
|
<el-button :icon="Search" />
|
|
|
</template>
|
|
|
</el-input>
|
|
|
- <div class="search-result" v-show="keyword" ref="resultEl"></div>
|
|
|
+ <div class="rrr">
|
|
|
+ <div class="search-result" v-show="keyword && showSearch" ref="resultEl"></div>
|
|
|
+ <div class="search-sh" v-show="keyword">
|
|
|
+ <el-button style="width: 100%" @click="showSearch = !showSearch">
|
|
|
+ {{ showSearch ? "收起" : "展开" }}搜索结果
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="def-select-map" ref="mapEl"></div>
|
|
|
+ <div class="def-select-map-layout">
|
|
|
+ <div class="def-select-map" ref="mapEl"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div class="def-map-info" v-if="info">
|
|
|
<p><span>纬度</span>{{ info.lat }}</p>
|
|
|
<p><span>经度</span>{{ info.lng }}</p>
|
|
@@ -26,9 +36,16 @@ export type MapImage = { blob: Blob | null; search: MapInfo | null };
|
|
|
type MapInfo = { lat: number; lng: number; zoom: number; text: string };
|
|
|
|
|
|
const keyword = ref("");
|
|
|
+const showSearch = ref(true);
|
|
|
const info = ref<MapInfo>();
|
|
|
const searchInfo = ref<MapInfo>();
|
|
|
|
|
|
+watchEffect(() => {
|
|
|
+ if (keyword.value) {
|
|
|
+ showSearch.value = true;
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
const mapEl = ref<HTMLDivElement>();
|
|
|
const resultEl = ref<HTMLDivElement>();
|
|
|
const searchAMap = ref<any>();
|
|
@@ -68,7 +85,9 @@ watchEffect(async (onCleanup) => {
|
|
|
|
|
|
placeSearch.on("listElementClick", (e) => {
|
|
|
setSearch(e.data);
|
|
|
+ showSearch.value = false;
|
|
|
});
|
|
|
+
|
|
|
placeSearch.on("complete", function (result) {
|
|
|
setTimeout(() => {
|
|
|
const markers = map.getAllOverlays("marker");
|
|
@@ -91,8 +110,12 @@ watchEffect(async (onCleanup) => {
|
|
|
};
|
|
|
};
|
|
|
//绑定地图移动与缩放事件
|
|
|
- map.on("moveend", () => (info.value = getMapInfo()));
|
|
|
- map.on("zoomend", () => (info.value = getMapInfo()));
|
|
|
+ map.on("moveend", () => {
|
|
|
+ info.value = getMapInfo();
|
|
|
+ });
|
|
|
+ map.on("zoomend", () => {
|
|
|
+ info.value = getMapInfo();
|
|
|
+ });
|
|
|
searchAMap.value = placeSearch;
|
|
|
|
|
|
onCleanup(() => {
|
|
@@ -130,11 +153,15 @@ defineExpose<QuiskExpose>({
|
|
|
z-index: 2;
|
|
|
}
|
|
|
|
|
|
-.search-result {
|
|
|
+.rrr {
|
|
|
position: absolute;
|
|
|
left: 0;
|
|
|
right: 0;
|
|
|
z-index: 1;
|
|
|
+}
|
|
|
+
|
|
|
+.search-sh,
|
|
|
+.search-result {
|
|
|
overflow: hidden;
|
|
|
|
|
|
&.show {
|
|
@@ -160,9 +187,19 @@ defineExpose<QuiskExpose>({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.def-select-map {
|
|
|
- width: 540px;
|
|
|
- height: 390px;
|
|
|
+.def-select-map-layout {
|
|
|
+ --scale: 1.5;
|
|
|
+ width: 100%;
|
|
|
+ padding-top: calc((390 / 540) * 100%);
|
|
|
+ position: relative;
|
|
|
z-index: 1;
|
|
|
}
|
|
|
+
|
|
|
+.def-select-map {
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
</style>
|