<div class="button" style="margin-top: 10rpx;" @click="poiSearchNearBy()" type="primary">查找周边建筑</div>
<scroll-view scroll-y="true">
<div class="div-font" v-for="(item,index) in pointAdd" v-bind:key="index">{{item.name}}</div>
</scroll-view>
</div>
</template>
<script>
export default {
data() {
return {
latitude: null,
longitude: null,
type: "wgs84",
scale: 17,
address: "",
pointAdd:[],
mapSearch:null
}
},
created(){
alert("页面被创建")
},
methods: {
//获取当前地址
getLocation() {
alert("获取当前经纬度")
let that = this;
uni.getLocation({
type: that.type,
success: res => {
alert(res.longitude)
that.longitude = res.longitude;
that.latitude = res.latitude;
}
});
},
currentAddress() {
alert("currentAddress")
let that = this;
that.mapSearch.reverseGeocode({
point: {
latitude: that.latitude,
longitude: that.longitude
}
}, ret => {
uni.showModal({
content: ret.address
})
})
},
poiSearchNearBy() {
alert("poiSearchNearBy")
let that = this;
that.mapSearch.poiSearchNearBy({
point: {
latitude: that.latitude,
longitude: that.longitude
},
key: '学校',
radius: 1000
}, ret => {
that.pointAdd = ret.poiList;
uni.showModal({
content: JSON.stringify(ret)
})
})
}
},
mounted() {
this.mapSearch = weex.requireModule('mapSearch')
this.getLocation();
}
}
</script>
<style>
.button {
width: 300px;
height: 50px;
color: #FFFFFF;
background-color: #DD524D;
border-radius: 10px;
align-items: center;
font-size: 30px;
padding-top: 15px;
}
.example {
flex-direction: column;
}
.map {
width: 750rpx;
height: 500rpx;
background-color: black;
}
.div-font{
font-size: 30px;
}
</style>
云端打包后安装到手机上,里面的方法都不执行,打包的时候勾选map权限了
2 个回复
GSCOSMOS - 一个热爱敲代码的家伙
同样的问题,请问您解决了吗
l***@163.com - 一个小白
同样的问题,请问您解决了吗