<map class="mapStyle" id="map" :latitude="latitude" :scale="scale" :min-scale="minScale" :max-scale="maxScale" :enable-satellite="enableSatellite"
:longitude="longitude" @regionchange="getCenterMap" :markers="markers" @markertap="markertap" @callouttap="markertap" show-location="true">
</map>
// maker展示
showMakers() {
for (var i=0;i<this.list.length;i++) {
// aes解密坐标
var deLng = CryptoJS.Decrypt(this.list[i].lng);
var deLat = CryptoJS.Decrypt(this.list[i].lat);
var color = '';
var borderColor = '';
var bgColor = '';
var iconPath = '';
var calloutContent = '';
calloutContent = this.list[i].positionName;
var marker = {
id: this.list[i].positionId,
longitude: parseFloat(deLng),
latitude: parseFloat(deLat),
iconPath: iconPath,
width: 15,
height: 15,
ifBuy: this.list[i].ifBuy,
callout: {
content: calloutContent,
color: color,
borderWidth: 0.5,
borderColor: borderColor,
bgColor: bgColor,
fontSize: 10,
borderRadius: 5,
padding: 2,
display: "ALWAYS",
}
};
this.markers.push(marker);
}
},
getCenterMap(e) {
// #ifdef MP-WEIXIN
var eType = e.type;
// #endif
// #ifdef MP-TOUTIAO
var eType = e.target.type;
// #endif
if (eType == 'end') {
let _this = this
this.mapContext.getCenterLocation({
success: (res) => {
if (res.longitude != 0) {
_this.longitude = parseFloat(res.longitude)
_this.latitude = parseFloat(res.latitude)
// N秒内不向后台获取数据
var feeQueryTime = uni.getStorageSync("feeQueryTime") || 0;
var nowDate = new Date().getTime().toFixed();
if ((parseInt(nowDate) - parseInt(feeQueryTime)) >= this.queryInterval) {
// 获取我的路标列表
_this.getList();
uni.setStorageSync("feeQueryTime", nowDate);
}
}
}
})
}
},
// 获取我的路标列表
getList() {
if (this.wxuserMobile) {
var url = ‘’;
uni.request({
url: url,
method: 'POST',
header: {'content-type': 'application/x-www-form-urlencoded'},
data: {
lng: this.longitude,
lat: this.latitude,
mobile: this.wxuserMobile
},
success: res => {
this.markers.splice(0, this.markers.length);
this.list.splice(0, this.list.length);
if (res.data.code == 0 && res.data.positionList != undefined) {
this.list = res.data.positionList;
this.showMakers();
} else {
this.list.splice(0, this.list.length);
}
}
});
}
},
码码儿 (作者)
已反馈到字节社区
2023-07-01 23:58