Compare commits
3 Commits
2f87639314
...
fa44229ed2
| Author | SHA1 | Date |
|---|---|---|
|
|
fa44229ed2 | |
|
|
ce1dc5b5a7 | |
|
|
409d761bbc |
|
|
@ -48,7 +48,7 @@ http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
|
||||||
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
|
'app-id' : uni.getAccountInfoSync().miniProgram.appId,
|
||||||
"client-type" : "MA",
|
"client-type" : "MA",
|
||||||
'third-session' : uni.getStorageSync('third_session')||'123',
|
'third-session' : uni.getStorageSync('third_session')||'123',
|
||||||
'X-Tenant-Id' : '1003'
|
'X-Tenant-Id' : '1002'
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name" : "稷山县县面源污染监测平台",
|
"name" : "吉县面源污染监测平台",
|
||||||
"appid" : "__UNI__A58A5D7",
|
"appid" : "__UNI__A58A5D7",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "2.2.22",
|
"versionName" : "2.2.22",
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wxca651c881cfb603f",
|
"appid" : "wxc078890f8668ed2e",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false,
|
"urlCheck" : false,
|
||||||
"es6" : true,
|
"es6" : true,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 稷山县县现代农业发展中心</text>
|
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 吉县现代农业发展中心</text>
|
||||||
<!-- <view class="loginpage">
|
<!-- <view class="loginpage">
|
||||||
<image class="bigimg" src="../../static/dls.jpg" mode=""></image>
|
<image class="bigimg" src="../../static/dls.jpg" mode=""></image>
|
||||||
<view class="padding text-center margin-top">
|
<view class="padding text-center margin-top">
|
||||||
|
|
@ -196,7 +196,7 @@ export default {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%);
|
transform: translate(-50%);
|
||||||
color: #999;
|
color: #999;
|
||||||
width: 52%;
|
width: 60%;
|
||||||
}
|
}
|
||||||
.login-paddingtop {
|
.login-paddingtop {
|
||||||
padding-top: 100upx;
|
padding-top: 100upx;
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 64 KiB |
|
|
@ -23,7 +23,7 @@
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 稷山县县现代农业发展中心</text>
|
<text class="botmTetx">Copyright <text style="font-size: 30rpx;padding:0rpx 7rpx;"> © </text> 吉县现代农业发展中心</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "稷山县县小流域面源污染监测",
|
"navigationBarTitleText": "吉县小流域面源污染监测",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<uni-nav-bar :fixed="true" leftWidth="00rpx" rightWidth="0rpx" background-color="transparent" status-bar title="稷山县农业面源污染在线监测小程序" />
|
<uni-nav-bar :fixed="true" leftWidth="00rpx" rightWidth="0rpx" background-color="transparent" status-bar title="吉县农业面源污染在线监测小程序" />
|
||||||
<image src="../../static/home_top_bg.png" mode="" class="bgimg"></image>
|
<image src="../../static/home_top_bg.png" mode="" class="bgimg"></image>
|
||||||
<scroll-view class="content" scroll-y="true" :style="{height:contentheight + 'rpx'}">
|
<scroll-view class="content" scroll-y="true" :style="{height:contentheight + 'rpx'}">
|
||||||
<view class="top_address">
|
<view class="top_address">
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
<view class="bot_mid">
|
<view class="bot_mid">
|
||||||
<view class="bot_mid_left"
|
<view class="bot_mid_left"
|
||||||
:class="{'bot_mid_lefts':item.type == 2 || item.type == 0}">
|
:class="{'bot_mid_lefts':item.type == 2 || item.type == 0}">
|
||||||
{{ (item.value !== null && item.value !== undefined && item.value !== '' && !isNaN(item.value)) ? item.value + (item.unit || '') : '0' }}{{ item.unit }}
|
{{ (item.value !== null && item.value !== undefined && item.value !== '' && !isNaN(item.value)) ? item.value + (item.unit || '') : '0' }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="bot_rig" v-if="item.times">
|
<view class="bot_rig" v-if="item.times">
|
||||||
|
|
@ -334,15 +334,18 @@
|
||||||
},
|
},
|
||||||
// banner跳转
|
// banner跳转
|
||||||
banlick(index){
|
banlick(index){
|
||||||
if (index==0) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/packDetail/pages/vidio/soilindex'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/packDetail/pages/Site/index'
|
url: '/packDetail/pages/Site/index'
|
||||||
})
|
})
|
||||||
}
|
// if (index==0) {
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: '/packDetail/pages/vidio/soilindex'
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: '/packDetail/pages/Site/index'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" scale="13" :markers="markers"
|
<map id="map" ref="map" style="width: 100%; height: calc(100vh + 50rpx);" :scale="mapScale" :markers="markers"
|
||||||
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale @markertap="markertap" >
|
longitude="112.83100231396601" latitude="36.872032399813556" show-location show-compass show-scale
|
||||||
|
@markertap="markertap">
|
||||||
</map>
|
</map>
|
||||||
<view class="zdxq">
|
<view class="zdxq">
|
||||||
<view class="zdxqitem" @click="switch2Change('livestock')">
|
<view class="zdxqitem" @click="switch2Change('livestock')">
|
||||||
|
|
@ -16,7 +17,7 @@
|
||||||
农田污染监测站
|
农田污染监测站
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zdxqitem" @click="switch2Change('watershed')">
|
<!-- <view class="zdxqitem" @click="switch2Change('watershed')">
|
||||||
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
|
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
小流域监测站
|
小流域监测站
|
||||||
|
|
@ -27,7 +28,7 @@
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
长期定位监测点
|
长期定位监测点
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -44,7 +45,7 @@
|
||||||
latitude: 36.5,
|
latitude: 36.5,
|
||||||
longitude: 111.7
|
longitude: 111.7
|
||||||
},
|
},
|
||||||
scale: 14,
|
mapScale: 13,
|
||||||
markers: [],
|
markers: [],
|
||||||
markersZIndex: 1,
|
markersZIndex: 1,
|
||||||
lastTap: '',
|
lastTap: '',
|
||||||
|
|
@ -57,31 +58,30 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {},
|
||||||
},
|
|
||||||
onReady() {
|
onReady() {
|
||||||
// 在onReady中初始化地图上下文
|
// 在onReady中初始化地图上下文
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
api.checkLogin(()=>{
|
api.checkLogin(() => {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.getList()
|
this.getList()
|
||||||
})
|
})
|
||||||
}, () => {
|
}, () => {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url:'/packDetail/pages/login/login'
|
url: '/packDetail/pages/login/login'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// kaihs
|
||||||
getList() {
|
getList() {
|
||||||
this.markers = []
|
this.markers = []
|
||||||
this.stationList = []
|
this.stationList = []
|
||||||
this.cusLocationList = []
|
this.cusLocationList = []
|
||||||
this.soilStationList = []
|
this.soilStationList = []
|
||||||
this.allStationList = []
|
this.allStationList = []
|
||||||
|
|
||||||
this.stationTwoList = []
|
this.stationTwoList = []
|
||||||
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
|
|
@ -89,19 +89,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
this.$http.get('/applet/survStationInfo/stationMap').then(res => {
|
||||||
|
// 处理数据
|
||||||
this.stationList = [...res.data.data.stationInfo];
|
this.stationList = [...res.data.data.stationInfo];
|
||||||
this.cusLocationList = [...res.data.data.cusLocation];
|
this.cusLocationList = [...res.data.data.cusLocation];
|
||||||
this.soilStationList = [...res.data.data.deviceList];
|
this.soilStationList = [...res.data.data.deviceList];
|
||||||
this.allStationList.push(...this.stationList);
|
this.allStationList.push(...this.stationList);
|
||||||
this.allStationList.push(...this.cusLocationList);
|
this.allStationList.push(...this.cusLocationList);
|
||||||
this.allStationList.push(...this.soilStationList);
|
this.allStationList.push(...this.soilStationList);
|
||||||
// console.log("合并后的stationlist+++++", this.allStationList);
|
|
||||||
// console.log("合并后的stationList+++++", this.stationList);
|
|
||||||
// console.log("合并后的cusLocationList+++++", this.cusLocationList);
|
|
||||||
// console.log("合并后的soilStationList+++++", this.soilStationList);
|
|
||||||
//stationType: "orient" 农田
|
|
||||||
//stationType: "livestock" 畜禽
|
|
||||||
//stationType: "watershed" 小流域
|
|
||||||
this.allStationList.forEach((item, index) => {
|
this.allStationList.forEach((item, index) => {
|
||||||
item.id = index;
|
item.id = index;
|
||||||
});
|
});
|
||||||
|
|
@ -109,34 +103,166 @@
|
||||||
this.issscd = false
|
this.issscd = false
|
||||||
this.isssscd = false
|
this.isssscd = false
|
||||||
this.isSoilShow = false
|
this.isSoilShow = false
|
||||||
this.enterpriseRender();// 企业渲染
|
|
||||||
this.stationRender();// 站点渲染
|
|
||||||
this.monitorRender() // 监测点渲染
|
|
||||||
|
|
||||||
// 延迟执行以确保标记已经添加到地图
|
// 渲染所有标记
|
||||||
setTimeout(() => {
|
this.enterpriseRender();
|
||||||
this.adjustMapToFitAllMarkers();
|
this.stationRender();
|
||||||
}, 500);
|
this.monitorRender()
|
||||||
|
|
||||||
|
// 使用增强的视野调整方法
|
||||||
|
this.ensureAllMarkersVisible();
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
}).catch(err => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '数据加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.error('加载地图数据失败:', err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
enterpriseRender() {//企业点位地图渲染
|
ensureAllMarkersVisible() {
|
||||||
|
// 确保地图上下文已初始化
|
||||||
|
if (!this.mapCtx) {
|
||||||
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 过滤出有效的坐标点
|
||||||
|
const validPoints = this.markers
|
||||||
|
.filter(item => {
|
||||||
|
const lat = Number(item.latitude);
|
||||||
|
const lng = Number(item.longitude);
|
||||||
|
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
||||||
|
})
|
||||||
|
.map(item => ({
|
||||||
|
latitude: Number(item.latitude),
|
||||||
|
longitude: Number(item.longitude)
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (validPoints.length === 0) {
|
||||||
|
console.warn('没有有效的坐标点');
|
||||||
|
// 如果有默认坐标,使用默认坐标
|
||||||
|
if (this.center.latitude && this.center.longitude) {
|
||||||
|
this.mapCtx.moveToLocation({
|
||||||
|
latitude: this.center.latitude,
|
||||||
|
longitude: this.center.longitude,
|
||||||
|
scale: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('有效坐标点数量:', validPoints.length);
|
||||||
|
|
||||||
|
// 方法1:使用 includePoints(优先)
|
||||||
|
try {
|
||||||
|
this.mapCtx.includePoints({
|
||||||
|
points: validPoints,
|
||||||
|
padding: [120, 120, 120, 120], // 增加边距让点位不贴边
|
||||||
|
success: () => {
|
||||||
|
console.log('地图视野调整成功');
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('includePoints失败:', err);
|
||||||
|
// 如果失败,使用备用方案
|
||||||
|
this.fallbackAdjustMap(validPoints);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('调整地图视野异常:', e);
|
||||||
|
this.fallbackAdjustMap(validPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方法2:延迟重试(确保地图完全渲染)
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.mapCtx) {
|
||||||
|
try {
|
||||||
|
this.mapCtx.includePoints({
|
||||||
|
points: validPoints,
|
||||||
|
padding: [150, 150, 150, 150]
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('第二次调整失败:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
// 方法3:第三次重试(更长的延迟)
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.mapCtx) {
|
||||||
|
try {
|
||||||
|
this.mapCtx.includePoints({
|
||||||
|
points: validPoints,
|
||||||
|
padding: [180, 160, 160, 160]
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('第三次调整失败:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
fallbackAdjustMap(validPoints) {
|
||||||
|
if (!validPoints || validPoints.length === 0) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 计算所有点位的中心点和范围
|
||||||
|
const lats = validPoints.map(p => p.latitude);
|
||||||
|
const lngs = validPoints.map(p => p.longitude);
|
||||||
|
|
||||||
|
const minLat = Math.min(...lats);
|
||||||
|
const maxLat = Math.max(...lats);
|
||||||
|
const minLng = Math.min(...lngs);
|
||||||
|
const maxLng = Math.max(...lngs);
|
||||||
|
|
||||||
|
// 计算中心点
|
||||||
|
const centerLat = (minLat + maxLat) / 2;
|
||||||
|
const centerLng = (minLng + maxLng) / 2;
|
||||||
|
|
||||||
|
// 计算合适的缩放级别
|
||||||
|
const latDiff = maxLat - minLat;
|
||||||
|
const lngDiff = maxLng - minLng;
|
||||||
|
const maxDiff = Math.max(latDiff, lngDiff);
|
||||||
|
|
||||||
|
let scale = 13;
|
||||||
|
if (maxDiff > 2) scale = 6;
|
||||||
|
else if (maxDiff > 1) scale = 8;
|
||||||
|
else if (maxDiff > 0.5) scale = 10;
|
||||||
|
else if (maxDiff > 0.2) scale = 11;
|
||||||
|
else if (maxDiff > 0.1) scale = 12;
|
||||||
|
else scale = 13;
|
||||||
|
|
||||||
|
console.log('备用方案 - 中心点:', centerLat, centerLng, '缩放:', scale);
|
||||||
|
|
||||||
|
// 移动地图到计算出的中心位置
|
||||||
|
this.mapCtx.moveToLocation({
|
||||||
|
latitude: centerLat,
|
||||||
|
longitude: centerLng,
|
||||||
|
scale: scale
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('备用方案失败:', e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enterpriseRender() {
|
||||||
for (let i = 0; i < this.cusLocationList.length; i++) {
|
for (let i = 0; i < this.cusLocationList.length; i++) {
|
||||||
const item = this.cusLocationList[i];
|
const item = this.cusLocationList[i];
|
||||||
item.iconPath = '/static/qiyeIcon.png';
|
const lat = Number(item.stationLatitude);
|
||||||
item.latitude = Number(item.stationLatitude);
|
const lng = Number(item.stationLongitude);
|
||||||
item.longitude = Number(item.stationLongitude);
|
|
||||||
item.width = 35;
|
// 验证坐标有效性
|
||||||
item.height = 52;
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
|
console.warn('企业点位坐标无效:', item.stationName, lat, lng);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id || `enterprise_${i}`,
|
||||||
iconPath: item.iconPath,
|
iconPath: '/static/qiyeIcon.png',
|
||||||
latitude: item.latitude,
|
latitude: lat,
|
||||||
longitude: item.longitude,
|
longitude: lng,
|
||||||
width: item.width,
|
width: 35,
|
||||||
height: item.height,
|
height: 52,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0,
|
anchorY: 0,
|
||||||
anchorX: 0,
|
anchorX: 0,
|
||||||
|
|
@ -145,29 +271,33 @@
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: false, //点聚合
|
joinCluster: false,
|
||||||
zIndex: this.markersZIndex,
|
zIndex: this.markersZIndex,
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stationRender() {// 站房点位置渲染
|
|
||||||
// this.markers = this.markers.filter(item => item.stationType !== 'orient');
|
stationRender() {
|
||||||
if (!this.issscd) {
|
if (!this.issscd) {
|
||||||
for (let i = 0; i < this.stationList.length; i++) {
|
for (let i = 0; i < this.stationList.length; i++) {
|
||||||
const item = this.stationList[i];
|
const item = this.stationList[i];
|
||||||
item.iconPath = this.baseUrl +'/'+ item.stationIcon;
|
const lat = Number(item.stationLatitude);
|
||||||
item.latitude = Number(item.stationLatitude);
|
const lng = Number(item.stationLongitude);
|
||||||
item.longitude = Number(item.stationLongitude);
|
|
||||||
item.width = 239;
|
// 验证坐标有效性
|
||||||
item.height = 186;
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
|
console.warn('站房点位坐标无效:', item.stationName, lat, lng);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id || `station_${i}`,
|
||||||
iconPath: item.iconPath,
|
iconPath: this.baseUrl + '/' + item.stationIcon,
|
||||||
latitude: item.latitude,
|
latitude: lat,
|
||||||
longitude: item.longitude,
|
longitude: lng,
|
||||||
width: item.width,
|
width: 239,
|
||||||
height: item.height,
|
height: 186,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: 0,
|
anchorY: 0,
|
||||||
anchorX: 0,
|
anchorX: 0,
|
||||||
|
|
@ -176,21 +306,30 @@
|
||||||
stationType: item.stationType,
|
stationType: item.stationType,
|
||||||
stationName: item.stationName,
|
stationName: item.stationName,
|
||||||
stationCode: item.stationCode,
|
stationCode: item.stationCode,
|
||||||
joinCluster: false, //点聚合
|
joinCluster: false,
|
||||||
zIndex: this.markersZIndex + 1,
|
zIndex: this.markersZIndex,
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
monitorRender() {// 监测点位渲染
|
|
||||||
|
monitorRender() {
|
||||||
this.soilStationList.forEach((item, index) => {
|
this.soilStationList.forEach((item, index) => {
|
||||||
|
const lat = Number(item.latitude);
|
||||||
|
const lng = Number(item.longitude);
|
||||||
|
|
||||||
|
// 验证坐标有效性
|
||||||
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
|
console.warn('监测点位坐标无效:', item.name, lat, lng);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let iconPath = '';
|
let iconPath = '';
|
||||||
let width = 35;
|
let width = 35;
|
||||||
let height = 35;
|
let height = 35;
|
||||||
// 根据设备类型设置不同的图标
|
|
||||||
switch(item.type) {
|
switch (item.type) {
|
||||||
case 'soil':
|
case 'soil':
|
||||||
iconPath = this.baseUrl + '/icon/device/soil.png';
|
iconPath = this.baseUrl + '/icon/device/soil.png';
|
||||||
width = 32;
|
width = 32;
|
||||||
|
|
@ -204,11 +343,12 @@
|
||||||
default:
|
default:
|
||||||
iconPath = this.baseUrl + '/icon/device/default.png';
|
iconPath = this.baseUrl + '/icon/device/default.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: item.id || `device_${index}`,
|
||||||
iconPath: iconPath,
|
iconPath: iconPath,
|
||||||
latitude: Number(item.latitude),
|
latitude: lat,
|
||||||
longitude: Number(item.longitude),
|
longitude: lng,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
|
|
@ -220,7 +360,7 @@
|
||||||
stationName: item.name,
|
stationName: item.name,
|
||||||
stationCode: item.ids,
|
stationCode: item.ids,
|
||||||
deviceType: item.type,
|
deviceType: item.type,
|
||||||
joinCluster: false, //点聚合
|
joinCluster: false,
|
||||||
zIndex: this.markersZIndex,
|
zIndex: this.markersZIndex,
|
||||||
};
|
};
|
||||||
this.markers.push(markerItem);
|
this.markers.push(markerItem);
|
||||||
|
|
@ -241,18 +381,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
switch2Change(name) {// 焦点显示图例
|
switch2Change(name) { // 焦点显示图例
|
||||||
// 更新对应区域的状态
|
// 更新对应区域的状态
|
||||||
//四种监测站:xuqin nongtian xiaoliuyu turang
|
|
||||||
let that = this;
|
let that = this;
|
||||||
if(name === that.lastTap){
|
if (name === that.lastTap) {
|
||||||
that.adjustMapToFitAllMarkers();
|
that.adjustMapToFitAllMarkers();
|
||||||
that.lastTap = '';
|
that.lastTap = '';
|
||||||
} else {
|
} else {
|
||||||
// 聚焦到特定区域
|
// 聚焦到特定区域
|
||||||
that.adjustMapToRegion(name);
|
that.adjustMapToRegion(name);
|
||||||
that.lastTap = name;
|
that.lastTap = name;
|
||||||
// 或者使用更精确的方法:this.preciseMapAdjustment(name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -260,7 +398,10 @@
|
||||||
adjustMapToFitAllMarkers() {
|
adjustMapToFitAllMarkers() {
|
||||||
if (this.mapCtx && this.markers.length > 0) {
|
if (this.mapCtx && this.markers.length > 0) {
|
||||||
this.mapCtx.includePoints({
|
this.mapCtx.includePoints({
|
||||||
points: this.markers.map(item => ({latitude: item.latitude, longitude: item.longitude})),
|
points: this.markers.map(item => ({
|
||||||
|
latitude: item.latitude,
|
||||||
|
longitude: item.longitude
|
||||||
|
})),
|
||||||
padding: [60, 60, 60, 60] // 上下左右的边距
|
padding: [60, 60, 60, 60] // 上下左右的边距
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -273,8 +414,6 @@
|
||||||
let that = this;
|
let that = this;
|
||||||
let points = [];
|
let points = [];
|
||||||
let markers = [];
|
let markers = [];
|
||||||
that.markersZIndex ++;
|
|
||||||
that.markersZIndex ++;
|
|
||||||
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
||||||
// 获取团柏河区域的所有标记点
|
// 获取团柏河区域的所有标记点
|
||||||
markers = this.markers.filter(item => item.stationType === regionName);
|
markers = this.markers.filter(item => item.stationType === regionName);
|
||||||
|
|
@ -283,13 +422,14 @@
|
||||||
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
markers = this.markers.filter(item => item.type === 'soil' || item.deviceType === 'soil');
|
||||||
}
|
}
|
||||||
console.log(this.markers)
|
console.log(this.markers)
|
||||||
if(markers.length > 0){
|
if (markers.length > 0) {
|
||||||
points = markers.map(item => {
|
points = markers.map(item => {
|
||||||
item.zIndex = that.markersZIndex;
|
item.zIndex = (that.markersZIndex++);
|
||||||
return {
|
return {
|
||||||
latitude: Number(item.latitude || item.stationLatitude),
|
latitude: Number(item.latitude || item.stationLatitude),
|
||||||
longitude: Number(item.longitude || item.stationLongitude)
|
longitude: Number(item.longitude || item.stationLongitude)
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (points.length > 0 && this.mapCtx) {
|
if (points.length > 0 && this.mapCtx) {
|
||||||
this.mapCtx.includePoints({
|
this.mapCtx.includePoints({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue