2***@qq.com
2***@qq.com
  • 发布:2020-02-19 09:50
  • 更新:2024-04-01 11:58
  • 阅读:655

用weex实现定位功能,为什么云端打包后页面的方法不执行?

分类:nvue
<template> <div class="item"> <map class="map" id="map1" ref="map1" :scale="scale" :markers="covers" show-location style="width: 100%; height: 300px;" latitude="latitude" :longitude="longitude"></map> <div class="button" @click="currentAddress()" type="primary">获取当前地址</div>
<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权限了

2020-02-19 09:50 负责人:无 分享
已邀请:
GSCOSMOS

GSCOSMOS - 一个热爱敲代码的家伙

同样的问题,请问您解决了吗

l***@163.com

l***@163.com

同样的问题,请问您解决了吗

要回复问题请先登录注册