feat(map): 添加地图定位功能的条件渲染控制

为了解决H5平台地图定位显示的问题,在index页面和pick-location页面中添加了
mapShowLocation响应式变量,并通过条件编译确保仅在非H5平台启用地图定位功能,
避免H5环境下出现定位相关的兼容性问题。
This commit is contained in:
2026-05-09 18:49:42 +08:00
parent a493d1bcf6
commit 3f3acf834d
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -48,6 +48,11 @@ const selectedSpot = ref(null);
const locating = ref(false); const locating = ref(false);
const mapCtx = ref(null); const mapCtx = ref(null);
const userLocation = ref(null); const userLocation = ref(null);
const mapShowLocation = ref(false);
// #ifndef H5
mapShowLocation.value = true;
// #endif
const truncate = (str, len = 8) => const truncate = (str, len = 8) =>
str && str.length > len ? str.slice(0, len) + "…" : str; str && str.length > len ? str.slice(0, len) + "…" : str;
@@ -390,7 +395,7 @@ onMounted(() => {
:longitude="mapCenter.longitude" :longitude="mapCenter.longitude"
:markers="markers" :markers="markers"
:scale="12" :scale="12"
:show-location="true" :show-location="mapShowLocation"
:enable-zoom="true" :enable-zoom="true"
:enable-scroll="true" :enable-scroll="true"
@markertap="onMarkerTap" @markertap="onMarkerTap"
+6 -1
View File
@@ -7,6 +7,11 @@ const longitude = ref(116.39747);
const address = ref("移动地图选择位置"); const address = ref("移动地图选择位置");
const currentCity = ref(""); const currentCity = ref("");
const mapCtx = ref(null); const mapCtx = ref(null);
const mapShowLocation = ref(false);
// #ifndef H5
mapShowLocation.value = true;
// #endif
const keyword = ref(""); const keyword = ref("");
const searchResults = ref([]); const searchResults = ref([]);
@@ -129,7 +134,7 @@ const confirmLocation = () => {
:latitude="latitude" :latitude="latitude"
:longitude="longitude" :longitude="longitude"
:scale="16" :scale="16"
show-location :show-location="mapShowLocation"
@regionchange="onRegionChange" @regionchange="onRegionChange"
/> />
<view class="center-pin"> <view class="center-pin">