2024-06-13 13:50:03 +08:00
|
|
|
|
<template>
|
2024-06-19 10:24:04 +08:00
|
|
|
|
<view>
|
2024-06-19 15:59:02 +08:00
|
|
|
|
<view class="page-section page-section-gap">
|
|
|
|
|
|
<map
|
2024-06-24 09:56:50 +08:00
|
|
|
|
style="width: 100%; height: 300px; flex: 1"
|
2024-06-19 15:59:02 +08:00
|
|
|
|
id="container"
|
|
|
|
|
|
:latitude="lnglat[1]"
|
|
|
|
|
|
:longitude="lnglat[0]"
|
|
|
|
|
|
enable-scroll
|
|
|
|
|
|
enable-rotate
|
|
|
|
|
|
></map>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
2024-06-19 10:24:04 +08:00
|
|
|
|
<view class="text">
|
|
|
|
|
|
<text class="tit">当前位置</text>
|
|
|
|
|
|
<view id="adds">{{ address }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="text">
|
|
|
|
|
|
<p class="tit">经/纬度</p>
|
|
|
|
|
|
|
|
|
|
|
|
<view
|
|
|
|
|
|
><span id="lng">{{ lnglat[0] }}, {{ lnglat[1] }}</span></view
|
|
|
|
|
|
>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<u-button
|
2024-07-01 10:58:49 +08:00
|
|
|
|
:disabled="!address"
|
2024-06-19 10:24:04 +08:00
|
|
|
|
type="primary"
|
|
|
|
|
|
text="确定"
|
|
|
|
|
|
customStyle="margin-top: 50px"
|
|
|
|
|
|
@click="backclick"
|
|
|
|
|
|
></u-button>
|
2024-06-13 13:50:03 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2024-06-19 10:24:04 +08:00
|
|
|
|
// import AMapLoader from '@amap/amap-jsapi-loader'
|
|
|
|
|
|
|
2024-06-13 13:50:03 +08:00
|
|
|
|
export default {
|
2024-06-19 10:24:04 +08:00
|
|
|
|
name: 'map-view',
|
2024-06-13 13:50:03 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2024-06-19 10:24:04 +08:00
|
|
|
|
lnglat: [109.139726, 29.665203],
|
|
|
|
|
|
geocoder: null,
|
|
|
|
|
|
marker: null,
|
|
|
|
|
|
geocoder: null,
|
|
|
|
|
|
address: null,
|
|
|
|
|
|
markers: [
|
|
|
|
|
|
{
|
|
|
|
|
|
latitude: 29.665203,
|
|
|
|
|
|
longitude: 109.139726,
|
|
|
|
|
|
iconPath: '../../static/tabs/add.png'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-06-19 15:59:02 +08:00
|
|
|
|
mounted () {
|
2024-07-01 09:35:40 +08:00
|
|
|
|
uni.showLoading({ title: '加载中...', mask: true })
|
2024-06-19 10:24:04 +08:00
|
|
|
|
this.initAMap()
|
|
|
|
|
|
},
|
2024-06-19 15:59:02 +08:00
|
|
|
|
onShow () {},
|
|
|
|
|
|
onLoad () {},
|
2024-06-19 10:24:04 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
backclick () {
|
|
|
|
|
|
this.$emit('back', this.lnglat, this.address)
|
|
|
|
|
|
},
|
|
|
|
|
|
mapClick (val) {
|
|
|
|
|
|
console.log('val', val)
|
|
|
|
|
|
},
|
|
|
|
|
|
initAMap () {
|
|
|
|
|
|
const self = this
|
2024-07-01 09:35:40 +08:00
|
|
|
|
console.log('erreee', 'wgs84', 'gcj02')
|
|
|
|
|
|
|
2024-06-19 10:24:04 +08:00
|
|
|
|
uni.getLocation({
|
2024-07-01 09:35:40 +08:00
|
|
|
|
type: 'wgs84',
|
2024-06-19 10:24:04 +08:00
|
|
|
|
isHighAccuracy: 'true',
|
|
|
|
|
|
geocode: 'true',
|
|
|
|
|
|
success: function (res) {
|
2024-07-01 09:35:40 +08:00
|
|
|
|
console.log('res----------', res)
|
2024-06-19 10:24:04 +08:00
|
|
|
|
const latitude = res.latitude
|
|
|
|
|
|
const longitude = res.longitude
|
2024-07-01 09:35:40 +08:00
|
|
|
|
|
2024-06-19 10:24:04 +08:00
|
|
|
|
self.lnglat = [longitude, latitude]
|
|
|
|
|
|
|
2024-07-01 09:35:40 +08:00
|
|
|
|
uni.hideLoading()
|
2024-06-19 10:24:04 +08:00
|
|
|
|
console.log('lnglatlnglat', self.lnglat, res)
|
|
|
|
|
|
console.log('地址', res.address)
|
2024-07-01 09:35:40 +08:00
|
|
|
|
|
2024-06-19 10:24:04 +08:00
|
|
|
|
if (res.address) {
|
2024-06-19 15:59:02 +08:00
|
|
|
|
let city = res.address.city ? res.address.city : ''
|
|
|
|
|
|
let district = res.address.district ? res.address.district : ''
|
|
|
|
|
|
let street = res.address.street ? res.address.street : ''
|
|
|
|
|
|
self.address = `${city}${district}${street}`
|
2024-06-19 10:24:04 +08:00
|
|
|
|
console.log('地址', self.address)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-06-13 13:50:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2024-06-19 10:24:04 +08:00
|
|
|
|
<style scoped>
|
2024-06-19 15:59:02 +08:00
|
|
|
|
.cont {
|
2024-06-13 13:50:03 +08:00
|
|
|
|
width: 100%;
|
2024-06-19 10:24:04 +08:00
|
|
|
|
height: 450px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.text {
|
|
|
|
|
|
margin: 10px;
|
|
|
|
|
|
padding-bottom: 10px;
|
|
|
|
|
|
border-bottom: 1px solid #eee;
|
2024-06-13 13:50:03 +08:00
|
|
|
|
}
|
2024-06-19 10:24:04 +08:00
|
|
|
|
.text .tit {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
font-weight: bold;
|
2024-06-13 13:50:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|