地图动态打点
This commit is contained in:
@ -702,7 +702,7 @@
|
||||
this.mqttClient.connect(() => {
|
||||
console.log('MQTT 连接成功,开始订阅主题');
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic = `A/${this.itemInfo.id}`;
|
||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||
// uni.showModal({
|
||||
|
@ -307,15 +307,23 @@
|
||||
},
|
||||
// *******定位******
|
||||
gpsPosition(item) {
|
||||
// 添加调试日志
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('MapData', {
|
||||
data: item
|
||||
});
|
||||
// 确保使用深拷贝
|
||||
const mapData = {
|
||||
deviceLocation: {
|
||||
longitude: String(item.longitude), // 强制转为字符串
|
||||
latitude: String(item.latitude),
|
||||
deviceImage: item.devicePic || '',
|
||||
deviceName: item.deviceImei || ''
|
||||
}
|
||||
}
|
||||
res.eventChannel.emit('MapData', JSON.parse(JSON.stringify(mapData)))
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -661,12 +669,6 @@
|
||||
});
|
||||
}
|
||||
})
|
||||
// const topic = `device/command/${this.deviceID}/message`;
|
||||
// this.mqttClient.publish(topic, this.messageToSend);
|
||||
// uni.showToast({
|
||||
// title: '消息已发送',
|
||||
// icon: 'success'
|
||||
// });
|
||||
},
|
||||
// 统一处理返回方法
|
||||
handleDeviceData(res, isFromShared = false) {
|
||||
@ -745,7 +747,7 @@
|
||||
this.mqttClient.connect(() => {
|
||||
console.log('MQTT 连接成功,开始订阅主题');
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic = `A/${this.deviceID}`;
|
||||
const statusTopic = `A/${this.itemInfo.deviceImei}`;
|
||||
this.mqttClient.subscribe(statusTopic, (payload) => {
|
||||
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
|
||||
// ✅ 发送全局事件通知主页面更新
|
||||
@ -928,12 +930,14 @@
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
text-align: end;
|
||||
}
|
||||
|
||||
.locationGPS {
|
||||
width: 88%;
|
||||
text-align: end;
|
||||
float: right;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
|
||||
.control-card {
|
||||
background-color: rgb(26, 26, 26);
|
||||
border-radius: 16rpx;
|
||||
|
@ -83,21 +83,26 @@ export default {
|
||||
this.map.on('complete', () => {
|
||||
document.getElementById('amapContainer').style.opacity = 1
|
||||
this.$ownerInstance.callMethod('hideLoading')
|
||||
|
||||
// 添加标记点
|
||||
const wuhanPoints = [
|
||||
{ lnglat: [114.404, 30.507], name: "华中科技大学" },
|
||||
{ lnglat: [114.428, 30.476], name: "光谷金融港" },
|
||||
{ lnglat: [114.433, 30.504], name: "武汉东站" }
|
||||
const wuhanPoints = [{
|
||||
lnglat: [114.404, 30.507],
|
||||
name: "华中科技大学"
|
||||
},
|
||||
{
|
||||
lnglat: [114.428, 30.476],
|
||||
name: "光谷金融港"
|
||||
},
|
||||
{
|
||||
lnglat: [114.433, 30.504],
|
||||
name: "武汉东站"
|
||||
}
|
||||
]
|
||||
wuhanPoints.forEach(point => {
|
||||
this.addMarker(point.lnglat, point.name)
|
||||
})
|
||||
})
|
||||
|
||||
// 创建自定义弹窗
|
||||
this.createCustomPopup()
|
||||
|
||||
} catch (e) {
|
||||
console.error('初始化失败:', e)
|
||||
this.$ownerInstance.callMethod('hideLoading')
|
||||
@ -122,11 +127,9 @@ export default {
|
||||
map: this.map,
|
||||
icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png',
|
||||
})
|
||||
|
||||
marker.on('click', () => {
|
||||
this.showCustomPopup(position, title)
|
||||
})
|
||||
|
||||
this.markers.push(marker)
|
||||
return marker
|
||||
},
|
||||
@ -137,7 +140,6 @@ export default {
|
||||
this.customPopup.style.display = 'block'
|
||||
this.customPopup.style.left = `${pixel.x}px`
|
||||
this.customPopup.style.top = `${pixel.y}px`
|
||||
|
||||
this.map.on('click', this.hideCustomPopup)
|
||||
},
|
||||
|
||||
@ -149,8 +151,8 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options,'optionsoptions');
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'detailData' 事件,获取传过来的数据
|
||||
eventChannel.on('MapData', (data) => {
|
||||
console.log(data, 'data');
|
||||
})
|
||||
@ -237,7 +239,14 @@ export default {
|
||||
}
|
||||
|
||||
@keyframes popupFadeIn {
|
||||
from { opacity: 0; transform: translate(-50%, -90%); }
|
||||
to { opacity: 1; transform: translate(-50%, -100%); }
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -90%);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -100%);
|
||||
}
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user