From 62c4f89a5db2f5594c782ef2b2bbb8941f63454f Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 13 Jan 2026 10:56:39 +0800
Subject: [PATCH] feat:地图搜索
---
applications/mobile-web-view/src/appPages/Map/searchBar.vue | 51 ++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/applications/mobile-web-view/src/appPages/Map/searchBar.vue b/applications/mobile-web-view/src/appPages/Map/searchBar.vue
index 15d4504..80cb7de 100644
--- a/applications/mobile-web-view/src/appPages/Map/searchBar.vue
+++ b/applications/mobile-web-view/src/appPages/Map/searchBar.vue
@@ -33,7 +33,7 @@
<van-list v-else :finished="finished" :finished-text="finishedText">
<van-cell v-for="item in list" :key="item" @click="flyToAddress(item)">
<template #title>{{ item.name }}</template>
- <template #value>{{ item.district }}</template>
+ <template #value>{{ item?.pname }}{{ item?.cityname }}{{ item?.adname }}</template>
</van-cell>
</van-list>
</van-floating-panel>
@@ -44,6 +44,7 @@
import { showToast } from 'vant'
import _ from 'lodash'
import { searchWithPlugin } from '@/utils/util'
+import { getPlace } from '@/api/map/address'
import { useStore } from 'vuex'
import EventBus from '@/utils/eventBus'
import { gcj02ToWgs84 } from '@/utils/coordinateTransformation'
@@ -62,8 +63,8 @@
const height = ref(anchors[0])
const curSearchType = ref(1) // 固定为地址搜索
-// 获取地址搜索结果
-const getAddressList = () => {
+// 使用插件搜索地址
+const searchWithPluginAPI = () => {
searchWithPlugin(searchVal.value, selectedAreaCode.value, (err, data) => {
if (data && data.length > 0) {
list.value = data
@@ -77,6 +78,36 @@
loadingTest.value = false
}, 800)
})
+}
+
+// 使用新接口搜索地址
+const searchWithNewAPI = () => {
+ getPlace({ keyworld: searchVal.value }).then(res => {
+ const data = res.data.data.pois || []
+ if (data && data.length > 0) {
+ list.value = data
+ finishedText.value = ''
+ } else {
+ finishedText.value = '暂无数据'
+ }
+
+ setTimeout(() => {
+ finished.value = true
+ loadingTest.value = false
+ }, 800)
+ }).catch(err => {
+ console.error('地址搜索失败:', err)
+ finishedText.value = '搜索失败'
+ setTimeout(() => {
+ finished.value = true
+ loadingTest.value = false
+ }, 800)
+ })
+}
+
+// 获取地址搜索结果
+const getAddressList = () => {
+ searchWithNewAPI()
}
const tooltipText = computed(() => {
@@ -122,13 +153,14 @@
showToast('当前地址无坐标信息')
return
}
-
- const [longitude, latitude] = gcj02ToWgs84(item.location.lng, item.location.lat)
+ const location = typeof item.location === 'string'
+ ? item.location.split(',').map(Number)
+ : [item.location.lng, item.location.lat];
+ const [longitude, latitude] = gcj02ToWgs84(location[0], location[1])
height.value = anchors[0]
searchVal.value = item.name
- inputSelect()
EventBus.emit('mapAddMarker', {
lat: latitude,
@@ -136,13 +168,6 @@
name: searchVal.value,
customClassName: 'address-marker',
})
-}
-
-const scanCode = () => {
- const transmitData = { data: { type: 'scanCode' } }
- wx.miniProgram.navigateTo({ url: "/subPackages/qrCode/index" })
- wx.miniProgram.postMessage(transmitData)
- uni.postMessage(transmitData)
}
watch(
--
Gitblit v1.9.3