|
@@ -128,46 +128,46 @@ const initData = (data) =>{
|
|
|
defalutAllPoints.value = []
|
|
|
totalList.value.forEach(item => map.value.remove(item.icon))
|
|
|
totalList.value = []
|
|
|
- // allPoints.value.forEach(item =>{
|
|
|
- // item.icon = new window.AMap.Marker({
|
|
|
- // position: item.lngLat,
|
|
|
- // map: map.value,
|
|
|
- // content: createMarkerContent(item.color),
|
|
|
- // offset: new window.AMap.Pixel(-7, -7),
|
|
|
- // extData: { id: item.id, priority: item.status > item.noImg > item.wys } // 标记优先级
|
|
|
- // });
|
|
|
- // item.type = 'defalutIcon'
|
|
|
+ allPoints.value.forEach(item =>{
|
|
|
+ item.icon = new window.AMap.Marker({
|
|
|
+ position: item.lnglat,
|
|
|
+ map: map.value,
|
|
|
+ content: createMarkerContent(item.color),
|
|
|
+ offset: new window.AMap.Pixel(-7, -7),
|
|
|
+ extData: { id: item.id, priority: item.status > item.noImg > item.wys } // 标记优先级
|
|
|
+ });
|
|
|
+ item.type = 'defalutIcon'
|
|
|
|
|
|
- // // 绑定点击事件
|
|
|
- // item.icon.on('click', () => {
|
|
|
- // mapEventType.value = 'click'
|
|
|
- // if(item.type === 'defalutIcon'){
|
|
|
- // item.icon.setContent(createMarkerImg());
|
|
|
- // item.icon.setOffset(new window.AMap.Pixel(-18, -18))
|
|
|
- // item.type = 'activeIcon'
|
|
|
- // const arr = pointList.value.filter(ele => ele.id === item.id)
|
|
|
- // if(arr.length===0){
|
|
|
- // pointList.value.push(item)
|
|
|
- // }
|
|
|
- // }else{
|
|
|
- // item.icon.setContent(createMarkerContent(item.color));
|
|
|
- // item.icon.setOffset(new window.AMap.Pixel(-7, -7))
|
|
|
- // item.type = 'defalutIcon'
|
|
|
- // }
|
|
|
+ // 绑定点击事件
|
|
|
+ item.icon.on('click', () => {
|
|
|
+ mapEventType.value = 'click'
|
|
|
+ if(item.type === 'defalutIcon'){
|
|
|
+ item.icon.setContent(createMarkerImg());
|
|
|
+ item.icon.setOffset(new window.AMap.Pixel(-18, -18))
|
|
|
+ item.type = 'activeIcon'
|
|
|
+ const arr = pointList.value.filter(ele => ele.id === item.id)
|
|
|
+ if(arr.length===0){
|
|
|
+ pointList.value.push(item)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ item.icon.setContent(createMarkerContent(item.color));
|
|
|
+ item.icon.setOffset(new window.AMap.Pixel(-7, -7))
|
|
|
+ item.type = 'defalutIcon'
|
|
|
+ }
|
|
|
|
|
|
- // setTimeout(()=>{
|
|
|
- // mapEventType.value = 'draw'
|
|
|
- // },100)
|
|
|
- // });
|
|
|
- // defalutAllPoints.value.push(item)
|
|
|
- // })
|
|
|
+ setTimeout(()=>{
|
|
|
+ mapEventType.value = 'draw'
|
|
|
+ },100)
|
|
|
+ });
|
|
|
+ defalutAllPoints.value.push(item)
|
|
|
+ })
|
|
|
// 初始化点聚合
|
|
|
- console.log('data',data);
|
|
|
- const cluster = new window.AMap.MarkerCluster(map.value, data, {
|
|
|
- gridSize: 60, // 聚合网格像素大小
|
|
|
- // maxZoom: 15, // 最大聚合级别
|
|
|
- // renderClusterMarker: customizeCluster // 自定义聚合样式
|
|
|
- });
|
|
|
+ // console.log('data',data);
|
|
|
+ // const cluster = new window.AMap.MarkerCluster(map.value, data, {
|
|
|
+ // gridSize: 30, // 聚合网格像素大小
|
|
|
+ // // maxZoom: 15, // 最大聚合级别
|
|
|
+ // // renderClusterMarker: customizeCluster // 自定义聚合样式
|
|
|
+ // });
|
|
|
setTimeout(()=>{
|
|
|
map.value.setFitView(null, false, [0, 0, 0, 0]);
|
|
|
},100)
|
|
@@ -208,7 +208,7 @@ const checkPointsInArea = () => {
|
|
|
if (!selectedArea.value) return;
|
|
|
const bounds = selectedArea.value.getBounds(); // 获取框选区域的边界
|
|
|
selectedPoints.value = allPoints.value.filter((point) => {
|
|
|
- return bounds.contains(point.lngLat); // 判断点位是否在框选区域内
|
|
|
+ return bounds.contains(point.lnglat); // 判断点位是否在框选区域内
|
|
|
});
|
|
|
|
|
|
selectedPoints.value.forEach(item =>{
|
|
@@ -224,25 +224,6 @@ const checkPointsInArea = () => {
|
|
|
})
|
|
|
};
|
|
|
|
|
|
-const speciesArr = ref([])
|
|
|
-const getList = () =>{
|
|
|
- const params = {
|
|
|
- farmId:sessionStorage.getItem('farmId'),
|
|
|
- regionId:sessionStorage.getItem('regionId')
|
|
|
- }
|
|
|
- VE_API.variety.pointList(params).then(res =>{
|
|
|
- allPoints.value = res.data.map(item =>{
|
|
|
- const bgColor = speciesArr.value.filter(ele =>ele.speciesItemId === item.speciesItemId)
|
|
|
- return{
|
|
|
- ...item,
|
|
|
- color:bgColor[0].color,
|
|
|
- lngLat:convertPointToArray(item.point)
|
|
|
- }
|
|
|
- })
|
|
|
- initData()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
const totalList = ref([])
|
|
|
|
|
|
function getSelectPoint(){
|
|
@@ -251,28 +232,15 @@ function getSelectPoint(){
|
|
|
return arr
|
|
|
}
|
|
|
|
|
|
-defineExpose({getSelectPoint,initData})
|
|
|
-
|
|
|
-function getSpeciesList(arr){
|
|
|
- speciesArr.value = arr
|
|
|
- getList()
|
|
|
-}
|
|
|
+defineExpose({getSelectPoint,initData,startRectangleSelection,stopDrawRectangle,clearSelection})
|
|
|
|
|
|
// 组件挂载时初始化地图
|
|
|
onMounted(() => {
|
|
|
initMap()
|
|
|
- eventBus.on('handle:clear',clearSelection)
|
|
|
- eventBus.on('species:list',getSpeciesList)
|
|
|
- eventBus.on('handle:start',startRectangleSelection)
|
|
|
- eventBus.on('handle:end',stopDrawRectangle)
|
|
|
});
|
|
|
|
|
|
onUnmounted(()=>{
|
|
|
map.value.destroy()// 销毁地图实例以释放资源
|
|
|
- eventBus.off('handle:clear',clearSelection)
|
|
|
- eventBus.off('species:list',getSpeciesList)
|
|
|
- eventBus.off('handle:start',startRectangleSelection)
|
|
|
- eventBus.off('handle:end',stopDrawRectangle)
|
|
|
})
|
|
|
</script>
|
|
|
|