湘妃到家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
1.4 KiB

<template>
<view class="map">
<view class="page-body">
<view class="page-section page-section-gap">
<map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers"></map>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'Map',
data() {
return {
id: 0, // 使用 marker点击事件 需要填写id
latitude: 0, //纬度
longitude: 0, //经度
covers: [{
latitude: 0,
longitude: 0,
iconPath: '../../static/map/location.png'
}]
}
},
onShow() {
let _self = this;
//获取用户当前位置
uni.getLocation({
type: 'gcj02', // 'wgs84'默认gps 坐标 'gcj02'国测
accuracy: 'best', // 精度值为20m
geocode: true,
isHighAccuracy : true,
success: function (res) {
_self.longitude = res.longitude
_self.latitude = res.latitude
_self.covers[0].longitude = res.longitude
_self.covers[0].latitude = res.latitude
}
});
uni.chooseLocation({
complete(res){ //成功或失败都会调
console.log(res);
},
success: function(res) { //成功回调
uni.navigateTo({
url: `/pages/mine/address?addressInfo=${JSON.stringify(res)}`
})
},
fail : function(res){
//定位获取失败或用户点击取消按钮触发
uni.navigateTo({
url: '/pages/mine/address'
})
}
});
}
}
</script>
<style lang="scss" scoped>
</style>