Compare commits
No commits in common. "2f876393144badd30666e9527db37d7524beae5b" and "eae52816825342acd2310bc9b373807f87e96550" have entirely different histories.
2f87639314
...
eae5281682
|
|
@ -1,24 +1,2 @@
|
||||||
.DS_Store
|
/unpackage/
|
||||||
node_modules
|
/.idea/
|
||||||
/dist
|
|
||||||
|
|
||||||
/unpackage
|
|
||||||
|
|
||||||
# local env files
|
|
||||||
.env.local
|
|
||||||
.env.*.local
|
|
||||||
|
|
||||||
# Log files
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
|
|
||||||
# Editor directories and files
|
|
||||||
.idea
|
|
||||||
.vscode
|
|
||||||
*.suo
|
|
||||||
*.ntvs*
|
|
||||||
*.njsproj
|
|
||||||
*.sln
|
|
||||||
*.sw?
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -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,17 +17,54 @@
|
||||||
农田污染监测站
|
农田污染监测站
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zdxqitem" @click="switch2Change('watershed')">
|
<view class="zdxqitem" @click="switch2Change('enterprise')">
|
||||||
<image src="../../static/zhandian_xiaoliuyu_dingwei.png" mode=""></image>
|
<image src="../../static/qiyebzIcon.png" mode="" style="width: 40rpx; height: 40rpx;"></image>
|
||||||
<view class="textss">
|
<view class="textss">
|
||||||
小流域监测站
|
企业监测点
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="zdxqitem" @click="switch2Change('soil')">
|
|
||||||
<image src="../../static/iconsheturangzs.png" mode=""></image>
|
|
||||||
<view class="textss">
|
|
||||||
长期定位监测点
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 企业信息弹出框 -->
|
||||||
|
<view class="enterprise-popup" v-if="showEnterprisePopup" @click="closePopup">
|
||||||
|
<view class="popup-content" @click.stop>
|
||||||
|
<view class="popup-header">
|
||||||
|
<text class="popup-title">{{ currentEnterprise.entName || '企业信息' }}</text>
|
||||||
|
<text class="popup-close" @click="closePopup">×</text>
|
||||||
|
</view>
|
||||||
|
<view class="popup-body">
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">企业简称:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entShortName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">负责人:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entCharge || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">统一信用代码:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entCredit || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">企业编号:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entCode || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">企业简介:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entIntro || '暂无简介' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">联系电话:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.entPhone || '暂无' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">创建时间:</text>
|
||||||
|
<text class="value">{{ currentEnterprise.createTime || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- <view class="popup-footer">
|
||||||
|
<button class="btn-detail" @click="goEnterpriseDetail">查看详情</button>
|
||||||
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -44,7 +82,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: '',
|
||||||
|
|
@ -53,14 +91,18 @@
|
||||||
soilStationList: [],
|
soilStationList: [],
|
||||||
allStationList: [],
|
allStationList: [],
|
||||||
stationTwoList: [],
|
stationTwoList: [],
|
||||||
mapCtx: null // 添加地图上下文
|
enterpriseList: [],
|
||||||
|
mapCtx: null,
|
||||||
|
showEnterprisePopup: false,
|
||||||
|
currentEnterprise: {},
|
||||||
|
currentMarkerId: null,
|
||||||
|
maxMarkerId: 0,
|
||||||
|
// 添加调试开关
|
||||||
|
debugMode: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {},
|
||||||
},
|
|
||||||
onReady() {
|
onReady() {
|
||||||
// 在onReady中初始化地图上下文
|
|
||||||
this.mapCtx = uni.createMapContext('map', this);
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|
@ -81,13 +123,14 @@
|
||||||
this.cusLocationList = []
|
this.cusLocationList = []
|
||||||
this.soilStationList = []
|
this.soilStationList = []
|
||||||
this.allStationList = []
|
this.allStationList = []
|
||||||
|
|
||||||
this.stationTwoList = []
|
this.stationTwoList = []
|
||||||
|
this.enterpriseList = []
|
||||||
|
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取监测站数据
|
||||||
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];
|
||||||
|
|
@ -95,101 +138,229 @@
|
||||||
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 + 1; // 从1开始
|
||||||
});
|
});
|
||||||
|
|
||||||
this.issscd = false
|
this.issscd = false
|
||||||
this.isssscd = false
|
this.isssscd = false
|
||||||
this.isSoilShow = false
|
this.isSoilShow = false
|
||||||
this.enterpriseRender();// 企业渲染
|
|
||||||
this.stationRender();// 站点渲染
|
|
||||||
this.monitorRender() // 监测点渲染
|
|
||||||
|
|
||||||
// 延迟执行以确保标记已经添加到地图
|
// 设置初始最大ID
|
||||||
setTimeout(() => {
|
this.maxMarkerId = this.allStationList.length + 1;
|
||||||
this.adjustMapToFitAllMarkers();
|
|
||||||
}, 500);
|
this.enterpriseRender();
|
||||||
|
this.stationRender();
|
||||||
|
this.monitorRender()
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
}).catch(err => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '数据加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.error('加载地图数据失败:', err);
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取企业列表
|
||||||
|
this.$http.get('/applet/wxclient/getEntList').then(res => {
|
||||||
|
if (res.data.data && res.data.data.result) {
|
||||||
|
this.enterpriseList = res.data.data.result;
|
||||||
|
this.renderEnterpriseMarkers();
|
||||||
|
this.ensureAllMarkersVisible();
|
||||||
|
}
|
||||||
|
uni.hideLoading();
|
||||||
|
}).catch(err => {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '企业数据加载失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.error('加载企业数据失败:', err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
enterpriseRender() {//企业点位地图渲染
|
|
||||||
for (let i = 0; i < this.cusLocationList.length; i++) {
|
renderEnterpriseMarkers() {
|
||||||
const item = this.cusLocationList[i];
|
if (!this.enterpriseList || this.enterpriseList.length === 0) {
|
||||||
item.iconPath = '/static/qiyeIcon.png';
|
console.warn('企业列表为空');
|
||||||
item.latitude = Number(item.stationLatitude);
|
return;
|
||||||
item.longitude = Number(item.stationLongitude);
|
}
|
||||||
item.width = 35;
|
|
||||||
item.height = 52;
|
|
||||||
|
this.enterpriseList.forEach((item, index) => {
|
||||||
|
const lat = Number(item.entLat);
|
||||||
|
const lng = Number(item.entLong);
|
||||||
|
|
||||||
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
|
console.warn('企业坐标无效:', item.entName, lat, lng);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const markerId = ++this.maxMarkerId;
|
||||||
|
|
||||||
|
let iconPath = '/static/qiyeIcon.png';
|
||||||
|
if (item.entMapIcon) {
|
||||||
|
iconPath = this.baseUrl + '/' + item.entMapIcon;
|
||||||
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: markerId,
|
||||||
iconPath: item.iconPath,
|
iconPath: iconPath,
|
||||||
latitude: item.latitude,
|
latitude: lat,
|
||||||
longitude: item.longitude,
|
longitude: lng,
|
||||||
width: item.width,
|
width: 40,
|
||||||
height: item.height,
|
height: 50,
|
||||||
customCallout: {
|
stationType: 'enterprise',
|
||||||
anchorY: 0,
|
stationName: item.entName,
|
||||||
anchorX: 0,
|
entShortName: item.entShortName,
|
||||||
|
entCharge: item.entCharge,
|
||||||
|
entCredit: item.entCredit,
|
||||||
|
entCode: item.entCode,
|
||||||
|
entIntro: item.entIntro,
|
||||||
|
entPhone: item.entPhone,
|
||||||
|
createTime: item.createTime,
|
||||||
|
entId: item.id,
|
||||||
|
joinCluster: false,
|
||||||
|
zIndex: this.markersZIndex++,
|
||||||
|
enterpriseData: item,
|
||||||
|
// 添加callout显示企业名称
|
||||||
|
callout: {
|
||||||
|
content: item.entName || '企业',
|
||||||
|
color: '#FFFFFF',
|
||||||
|
fontSize: 14,
|
||||||
|
borderRadius: 10,
|
||||||
|
bgColor: '#007AFF',
|
||||||
|
padding: 8,
|
||||||
display: 'ALWAYS'
|
display: 'ALWAYS'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.markers.push(markerItem);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
markertap(e) {
|
||||||
|
const index = e.detail.markerId;
|
||||||
|
// 查找匹配的marker
|
||||||
|
const marker = this.markers.find(m => Number(m.id) === Number(index));
|
||||||
|
|
||||||
|
|
||||||
|
if (!marker) {
|
||||||
|
console.warn('未找到对应的marker, ID:', index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (marker.stationType === 'enterprise') {
|
||||||
|
this.currentEnterprise = marker.enterpriseData || {
|
||||||
|
entName: marker.stationName || '企业名称',
|
||||||
|
entShortName: marker.entShortName || '',
|
||||||
|
entCharge: marker.entCharge || '',
|
||||||
|
entCredit: marker.entCredit || '',
|
||||||
|
entCode: marker.entCode || '',
|
||||||
|
entIntro: marker.entIntro || '暂无简介',
|
||||||
|
entPhone: marker.entPhone || '暂无',
|
||||||
|
createTime: marker.createTime || ''
|
||||||
|
};
|
||||||
|
|
||||||
|
this.currentMarkerId = marker.id;
|
||||||
|
this.showEnterprisePopup = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 原有的监测站逻辑
|
||||||
|
if (['orient', 'livestock'].includes(marker.stationType)) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
|
||||||
|
})
|
||||||
|
} else if (marker.stationType === 'device') {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/packDetail/pages/vidio/soilindex`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 关闭企业信息弹窗
|
||||||
|
closePopup() {
|
||||||
|
this.showEnterprisePopup = false;
|
||||||
|
this.currentEnterprise = {};
|
||||||
|
this.currentMarkerId = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
enterpriseRender() {
|
||||||
|
for (let i = 0; i < this.cusLocationList.length; i++) {
|
||||||
|
const item = this.cusLocationList[i];
|
||||||
|
const lat = Number(item.stationLatitude);
|
||||||
|
const lng = Number(item.stationLongitude);
|
||||||
|
|
||||||
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
|
console.warn('企业点位坐标无效:', item.stationName, lat, lng);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const markerItem = {
|
||||||
|
id: ++this.maxMarkerId,
|
||||||
|
iconPath: '/static/qiyeIcon.png',
|
||||||
|
latitude: lat,
|
||||||
|
longitude: lng,
|
||||||
|
width: 35,
|
||||||
|
height: 52,
|
||||||
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;
|
if (isNaN(lat) || isNaN(lng) || lat === 0 || lng === 0) {
|
||||||
item.height = 186;
|
console.warn('站房点位坐标无效:', item.stationName, lat, lng);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: ++this.maxMarkerId,
|
||||||
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: {
|
|
||||||
anchorY: 0,
|
|
||||||
anchorX: 0,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
},
|
|
||||||
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';
|
||||||
|
|
@ -204,104 +375,151 @@
|
||||||
default:
|
default:
|
||||||
iconPath = this.baseUrl + '/icon/device/default.png';
|
iconPath = this.baseUrl + '/icon/device/default.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
const markerItem = {
|
const markerItem = {
|
||||||
id: item.id,
|
id: ++this.maxMarkerId,
|
||||||
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: {
|
|
||||||
anchorY: 0,
|
|
||||||
anchorX: 0,
|
|
||||||
display: 'ALWAYS'
|
|
||||||
},
|
|
||||||
stationType: 'device',
|
stationType: 'device',
|
||||||
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);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
markertap(e) {
|
|
||||||
const index = e.detail.markerId
|
ensureAllMarkersVisible() {
|
||||||
const marker = this.markers.find(m => m.id === index);
|
if (!this.mapCtx) {
|
||||||
if (marker) {
|
this.mapCtx = uni.createMapContext('map', this);
|
||||||
if (['orient', 'livestock'].includes(marker.stationType)) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/packDetail/pages/Site/detail?item=${encodeURIComponent(JSON.stringify(marker))}`
|
|
||||||
})
|
|
||||||
} else if (marker.stationType === 'device') {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/packDetail/pages/vidio/soilindex`
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
if (this.center.latitude && this.center.longitude) {
|
||||||
|
this.mapCtx.moveToLocation({
|
||||||
|
latitude: this.center.latitude,
|
||||||
|
longitude: this.center.longitude,
|
||||||
|
scale: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.mapCtx.includePoints({
|
||||||
|
points: validPoints,
|
||||||
|
padding: [80, 80, 80, 80]
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('调整地图视野异常:', e);
|
||||||
|
this.fallbackAdjustMap(validPoints);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
switch2Change(name) {// 焦点显示图例
|
|
||||||
// 更新对应区域的状态
|
fallbackAdjustMap(validPoints) {
|
||||||
//四种监测站:xuqin nongtian xiaoliuyu turang
|
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;
|
||||||
|
|
||||||
|
this.mapCtx.moveToLocation({
|
||||||
|
latitude: centerLat,
|
||||||
|
longitude: centerLng,
|
||||||
|
scale: scale
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('备用方案失败:', e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
switch2Change(name) {
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 调整地图视野以包含所有标记点(类似setFitView效果)
|
|
||||||
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 => ({
|
||||||
padding: [60, 60, 60, 60] // 上下左右的边距
|
latitude: item.latitude,
|
||||||
|
longitude: item.longitude
|
||||||
|
})),
|
||||||
|
padding: [60, 60, 60, 60]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustMapToRegion(regionName) {
|
adjustMapToRegion(regionName) {
|
||||||
// 调整地图视野到特定区域的标记点
|
|
||||||
//stationType: "orient" 农田
|
|
||||||
//stationType: "livestock" 畜禽
|
|
||||||
//stationType: "watershed" 小流域
|
|
||||||
let that = this;
|
let that = this;
|
||||||
let points = [];
|
let points = [];
|
||||||
let markers = [];
|
let markers = [];
|
||||||
that.markersZIndex ++;
|
|
||||||
that.markersZIndex ++;
|
if (regionName === 'enterprise') {
|
||||||
if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
markers = this.markers.filter(item => item.stationType === 'enterprise');
|
||||||
// 获取团柏河区域的所有标记点
|
} else if (regionName === 'orient' || regionName === 'livestock' || regionName === 'watershed') {
|
||||||
markers = this.markers.filter(item => item.stationType === regionName);
|
markers = this.markers.filter(item => item.stationType === regionName);
|
||||||
} else if (regionName === 'soil') {
|
} else if (regionName === 'soil') {
|
||||||
// 获取所有土壤设备标记点
|
|
||||||
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)
|
|
||||||
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({
|
||||||
points: points,
|
points: points,
|
||||||
padding: [80, 110, 80, 110] // 增加边距以获得更好的显示效果
|
padding: [80, 110, 80, 110]
|
||||||
});
|
});
|
||||||
} else if (points.length === 0) {
|
|
||||||
// 如果没有找到对应的标记点,显示提示
|
|
||||||
// uni.showToast({
|
|
||||||
// title: `未找到${regionName}相关的监测点`,
|
|
||||||
// icon: 'none'
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -312,7 +530,6 @@
|
||||||
/* 样式保持不变 */
|
/* 样式保持不变 */
|
||||||
.bgimg {
|
.bgimg {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
// z-index: -99;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -326,7 +543,6 @@
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
// background-image: url('@/static/zhandian_icon_nongtian_title.png');
|
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100%;
|
background-size: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -341,7 +557,6 @@
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
text-shadow: 1rpx 2rpx 0rpx #0D1934;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
// background-image: url('@/static/zhandian_icon_xuqin_title.png');
|
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 100%;
|
background-size: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -415,4 +630,91 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 企业信息弹窗样式 */
|
||||||
|
.enterprise-popup {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-content {
|
||||||
|
width: 600rpx;
|
||||||
|
max-height: 70vh;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-header {
|
||||||
|
padding: 30rpx 30rpx 20rpx;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-title {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-close {
|
||||||
|
font-size: 48rpx;
|
||||||
|
color: #999;
|
||||||
|
padding: 0 10rpx;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-body {
|
||||||
|
padding: 20rpx 30rpx;
|
||||||
|
overflow-y: auto;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
display: flex;
|
||||||
|
padding: 12rpx 0;
|
||||||
|
font-size: 28rpx;
|
||||||
|
border-bottom: 1px solid #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item .label {
|
||||||
|
color: #666;
|
||||||
|
width: 160rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item .value {
|
||||||
|
color: #333;
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-footer {
|
||||||
|
padding: 20rpx 30rpx 30rpx;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-detail {
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
background: #007AFF;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 30rpx;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue