查看位置修改逻辑调整

test
zhangdi 1 year ago
parent 4b72ed472b
commit e4368f71b8
  1. 94
      pages/order/location.vue

@ -14,6 +14,18 @@
:enable-satellite="false" :enable-traffic="true" :show-location="true" :latitude="latitude" :enable-satellite="false" :enable-traffic="true" :show-location="true" :latitude="latitude"
:longitude="longitude" :markers="markers"> :longitude="longitude" :markers="markers">
</map> </map>
<cover-view class="controls-title">
<cover-view class="tabs_box">
<cover-view class="flex flex-sub">
<cover-view class="pay_name">维修人员张三</cover-view>
<cover-view class="pay_name" style="margin-top: 16rpx;">电话15089098908</cover-view>
<cover-view class="text-gray margin-top" style="margin-top: 16rpx;">
距离您还有 {{ juli }}
</cover-view>
</cover-view>
</cover-view>
</cover-view>
</view> </view>
</template> </template>
@ -21,51 +33,51 @@
/* /*
markers 获取维修人员的位置信息 markers 获取维修人员的位置信息
latitude和longitude 显示目的地的位置 latitude和longitude 显示目的地的位置
*/ */
export default { export default {
data() { data() {
return { return {
juli: null,//
scale: 16,// 5-18 scale: 16,// 5-18
latitude: 36.146504,//--- latitude: 36.146504,//---
longitude: 120.486065, // longitude: 120.486065, //
display: 'always',
markers: [{ markers: [{
id: 1, id: 1,
latitude: 36.146504,// latitude: 36.146504,//
longitude: 120.486065,// longitude: 120.486065,//
height: 160,// iconPath: '/static/images/position/destination.png',//
width: 160, label: {
callout: { content: '标记133',
color: '#007AFF', //
bgColor: '#fff', //
display: "ALWAYS", // 'BYCLICK':; 'ALWAYS':
fontSize: 15,
textAlign: 'left', // : left, right, center
padding: 10, //
borderRadius: 5,
content: '距离5km',
}, },
callout: {
iconPath: '/static/images/position/destination.png'// content: '20',
color: '#fff',
fontSize: 14,
borderRadius: 4,
bgColor: '#2B73FF',
display: 'ALWAYS',
padding: 3,
anchorY: 5
}
}, },
{ {
id:2, id: 2,
latitude: 35.146504,// latitude: 35.146504,//
longitude: 116.486065,// longitude: 116.486065,//
height: 160,// iconPath: '/static/images/position/weixiu.png',//
width: 160, display: 'ALWAYS',
callout: { callout: {
color: '#007AFF', // content: '标记25',
bgColor: '#fff', // color: '#ffffff',
display: "ALWAYS", // 'BYCLICK':; 'ALWAYS': fontSize: 14,
fontSize: 15, borderRadius: 4,
textAlign: 'left', // : left, right, center bgColor: '#3cc51f',
padding: 10, // display: "ALWAYS",
borderRadius: 5,
content: '距离5km',
}, },
iconPath: '/static/images/position/weixiu.png'//
}] }],
}; };
}, },
methods: { methods: {
@ -75,7 +87,7 @@ export default {
}, },
// //
getDistances(lat1, lng1, lat2, lng2) { getDistances(lat1, lng1, lat2, lng2) {
console.log('计算距离',lat1, lng1, lat2, lng2) console.log('计算距离', lat1, lng1, lat2, lng2)
var radLat1 = this.rad(lat1); var radLat1 = this.rad(lat1);
var radLat2 = this.rad(lat2); var radLat2 = this.rad(lat2);
@ -98,7 +110,8 @@ export default {
distance: distance, distance: distance,
distance_str: distance_str distance_str: distance_str
} }
this.markers[0].callout.content = '距离您' + objData.distance_str // this.markers[0].callout.content = '' + objData.distance_str
this.juli = objData.distance_str
}, },
// //
getLocation() { getLocation() {
@ -107,10 +120,10 @@ export default {
// success: (res) => { // success: (res) => {
// this.latitude = res.latitude// // this.latitude = res.latitude//
// this.longitude = res.longitude // this.longitude = res.longitude
this.markers[1].latitude = this.latitude+20// this.markers[1].latitude = this.latitude + 20//
this.markers[1].longitude = this.longitude+20 this.markers[1].longitude = this.longitude + 20
// console.log(':', res,this.markers); // console.log(':', res,this.markers);
this.getDistances(this.markers[1].latitude, this.markers[1].longitude,this.markers[0].latitude, this.markers[0].longitude) this.getDistances(this.markers[1].latitude, this.markers[1].longitude, this.markers[0].latitude, this.markers[0].longitude)
// }, // },
// fail: (err) => { // fail: (err) => {
// this.error = err; // this.error = err;
@ -128,4 +141,19 @@ export default {
}; };
</script> </script>
<style scoped></style> <style lang="scss" scoped>
.controls-title {
width: 90%;
min-height: 100rpx;
position: fixed;
left: 5%;
bottom: 200rpx;
background: #FFFFFF;
box-shadow: 0rpx 30rpx 40rpx 0rpx rgba(187, 170, 163, 0.20);
border-radius: 26rpx;
.tabs_box {
padding: 32rpx 32rpx 32rpx;
}
}
</style>
Loading…
Cancel
Save