|
@@ -15,7 +15,8 @@
|
|
:markers="data.covers" :show-location="true"> </map>
|
|
:markers="data.covers" :show-location="true"> </map>
|
|
|
|
|
|
<view v-if="result" class="map-card-list">
|
|
<view v-if="result" class="map-card-list">
|
|
- <view v-for="(item,index) in result.data.data" key="index" @click="xuanzeAdress(item)" class="map-card-box">
|
|
|
|
|
|
+ <!-- #ifdef H5 -->
|
|
|
|
+ <view v-for="(item,index) in result.data" key="index" @click="xuanzeAdress(item)" class="map-card-box">
|
|
<view>
|
|
<view>
|
|
<view class="map-card-title"><text v-if="index==0" class="dqwz-text">当前位置</text>{{item.title}}
|
|
<view class="map-card-title"><text v-if="index==0" class="dqwz-text">当前位置</text>{{item.title}}
|
|
</view>
|
|
</view>
|
|
@@ -23,7 +24,17 @@
|
|
</view>
|
|
</view>
|
|
<icon class="map-active-icon" v-if="index==0"></icon>
|
|
<icon class="map-active-icon" v-if="index==0"></icon>
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
|
|
+ <!-- #endif -->
|
|
|
|
+ <!-- #ifdef APP -->
|
|
|
|
+ <view v-for="(item,index) in result.data.data" key="index" @click="xuanzeAdress(item)" class="map-card-box">
|
|
|
|
+ <view>
|
|
|
|
+ <view class="map-card-title"><text v-if="index==0" class="dqwz-text">当前位置</text>{{item.title}}
|
|
|
|
+ </view>
|
|
|
|
+ <view class="map-card-address">{{item.address}}</view>
|
|
|
|
+ </view>
|
|
|
|
+ <icon class="map-active-icon" v-if="index==0"></icon>
|
|
|
|
+ </view>
|
|
|
|
+ <!-- #endif -->
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -64,26 +75,48 @@
|
|
function onSuccess(res) {
|
|
function onSuccess(res) {
|
|
console.log('数据', res);
|
|
console.log('数据', res);
|
|
result.value = res
|
|
result.value = res
|
|
- if (res.data && res.data.data && res.data.data.length > 0) {
|
|
|
|
- // 获取第一个搜索结果的经纬度
|
|
|
|
- const firstResult = res.data.data[0];
|
|
|
|
- const newLatitude = firstResult.location.lat; // 纬度
|
|
|
|
- const newLongitude = firstResult.location.lng; // 经度
|
|
|
|
-
|
|
|
|
- // 更新地图的中心点
|
|
|
|
- data.latitude = newLatitude;
|
|
|
|
- data.longitude = newLongitude;
|
|
|
|
-
|
|
|
|
- // 更新标记点
|
|
|
|
- data.covers = [{
|
|
|
|
- latitude: newLatitude,
|
|
|
|
- longitude: newLongitude,
|
|
|
|
- iconPath: myIcon, // 使用你的图标路径
|
|
|
|
- width: 30,
|
|
|
|
- height: 30
|
|
|
|
- }];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
+ if (res && res.data && res.data.length > 0) {
|
|
|
|
+ // 获取第一个搜索结果的经纬度
|
|
|
|
+ const firstResult = res.data[0];
|
|
|
|
+ const newLatitude = firstResult.location.lat; // 纬度
|
|
|
|
+ const newLongitude = firstResult.location.lng; // 经度
|
|
|
|
+
|
|
|
|
+ // 更新地图的中心点
|
|
|
|
+ data.latitude = newLatitude;
|
|
|
|
+ data.longitude = newLongitude;
|
|
|
|
+
|
|
|
|
+ // 更新标记点
|
|
|
|
+ data.covers = [{
|
|
|
|
+ latitude: newLatitude,
|
|
|
|
+ longitude: newLongitude,
|
|
|
|
+ iconPath: myIcon, // 使用你的图标路径
|
|
|
|
+ width: 30,
|
|
|
|
+ height: 30
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ // #endif
|
|
|
|
+ // #ifdef APP
|
|
|
|
+ if (res.data && res.data.data && res.data.data.length > 0) {
|
|
|
|
+ // 获取第一个搜索结果的经纬度
|
|
|
|
+ const firstResult = res.data.data[0];
|
|
|
|
+ const newLatitude = firstResult.location.lat; // 纬度
|
|
|
|
+ const newLongitude = firstResult.location.lng; // 经度
|
|
|
|
+
|
|
|
|
+ // 更新地图的中心点
|
|
|
|
+ data.latitude = newLatitude;
|
|
|
|
+ data.longitude = newLongitude;
|
|
|
|
+
|
|
|
|
+ // 更新标记点
|
|
|
|
+ data.covers = [{
|
|
|
|
+ latitude: newLatitude,
|
|
|
|
+ longitude: newLongitude,
|
|
|
|
+ iconPath: myIcon, // 使用你的图标路径
|
|
|
|
+ width: 30,
|
|
|
|
+ height: 30
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ // #endif
|
|
}
|
|
}
|
|
|
|
|
|
function onError(err) {
|
|
function onError(err) {
|