112 lines
2.5 KiB
Vue
112 lines
2.5 KiB
Vue
<template>
|
||
<view>
|
||
<!-- <map id="container" latitude="39.9" longitude="116.4"></map> -->
|
||
<map
|
||
id="container"
|
||
:latitude="lnglat[1]"
|
||
:longitude="lnglat[0]"
|
||
enable-scroll
|
||
enable-rotate
|
||
></map>
|
||
<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
|
||
type="primary"
|
||
text="确定"
|
||
customStyle="margin-top: 50px"
|
||
@click="backclick"
|
||
></u-button>
|
||
</view>
|
||
</template>
|
||
<script>
|
||
// import AMapLoader from '@amap/amap-jsapi-loader'
|
||
|
||
export default {
|
||
name: 'map-view',
|
||
data () {
|
||
return {
|
||
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'
|
||
}
|
||
]
|
||
}
|
||
},
|
||
mounted () {},
|
||
onShow () {},
|
||
onLoad () {
|
||
this.initAMap()
|
||
},
|
||
methods: {
|
||
backclick () {
|
||
this.$emit('back', this.lnglat, this.address)
|
||
},
|
||
mapClick (val) {
|
||
console.log('val', val)
|
||
},
|
||
initAMap () {
|
||
const self = this
|
||
console.log('erreee')
|
||
uni.getLocation({
|
||
type: 'gcj02',
|
||
isHighAccuracy: 'true',
|
||
geocode: 'true',
|
||
success: function (res) {
|
||
console.log('res', res)
|
||
|
||
const latitude = res.latitude
|
||
const longitude = res.longitude
|
||
// this.lnglat = [109.139726, 29.665203]
|
||
self.lnglat = [longitude, latitude]
|
||
// this.lnglat = [res.longitude, res.latitude]
|
||
|
||
console.log('lnglatlnglat', self.lnglat, res)
|
||
console.log('地址', res.address)
|
||
if (res.address) {
|
||
console.log('地址', res.address.province)
|
||
self.address =
|
||
res.address.province +
|
||
res.address.city +
|
||
res.address.district +
|
||
res.address.street +
|
||
res.address.poiName
|
||
console.log('地址', self.address)
|
||
}
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<style scoped>
|
||
#container {
|
||
width: 100%;
|
||
height: 450px;
|
||
}
|
||
.text {
|
||
margin: 10px;
|
||
padding-bottom: 10px;
|
||
border-bottom: 1px solid #eee;
|
||
}
|
||
.text .tit {
|
||
font-size: 14px;
|
||
font-weight: bold;
|
||
}
|
||
</style>
|