|
@ -1,7 +1,9 @@ |
|
|
import { reactive } from 'vue'; |
|
|
import { reactive } from 'vue'; |
|
|
import * as SyCim from 'sy-cesium-sdk'; |
|
|
import * as SyCim from 'sy-cesium-sdk'; |
|
|
import { LayerTypeEnum } from '@/enums/projectEnum'; |
|
|
import { LayerTypeEnum } from '@/enums/projectEnum'; |
|
|
|
|
|
import { queryLayersByPos } from "@/utils/mapUtils"; |
|
|
import axios from 'axios'; |
|
|
import axios from 'axios'; |
|
|
|
|
|
import { throttle } from "lodash-es"; |
|
|
const clustering = reactive({ |
|
|
const clustering = reactive({ |
|
|
enabled: true, |
|
|
enabled: true, |
|
|
pixelRange: 200, |
|
|
pixelRange: 200, |
|
@ -105,7 +107,7 @@ const layerActions: Record<string, any> = { |
|
|
|
|
|
|
|
|
export const getFeatures: any = (data: any, filter: '1=1') => { |
|
|
export const getFeatures: any = (data: any, filter: '1=1') => { |
|
|
return new Promise(async (resolve, reject) => { |
|
|
return new Promise(async (resolve, reject) => { |
|
|
const { url } = data; |
|
|
const { url, serviceToken } = data; |
|
|
let newUrl = decodeURI(url).split("maps/")[0].replace("map-", "data-"); |
|
|
let newUrl = decodeURI(url).split("maps/")[0].replace("map-", "data-"); |
|
|
const reg2 = /([^/]+)$/; |
|
|
const reg2 = /([^/]+)$/; |
|
|
const decodeUrl: any = decodeURI(url); |
|
|
const decodeUrl: any = decodeURI(url); |
|
@ -113,16 +115,20 @@ export const getFeatures: any = (data: any, filter: '1=1') => { |
|
|
const l = newLayerName?.split("%40"); |
|
|
const l = newLayerName?.split("%40"); |
|
|
const datasourceName = `${l?.[1]}:${l?.[0]}`; |
|
|
const datasourceName = `${l?.[1]}:${l?.[0]}`; |
|
|
let queryUrl = `${newUrl}data/featureResults.geojson?returnContent=true`; |
|
|
let queryUrl = `${newUrl}data/featureResults.geojson?returnContent=true`; |
|
|
|
|
|
let params: any = { |
|
|
|
|
|
getFeatureMode: 'SQL', |
|
|
|
|
|
datasetNames: [datasourceName], |
|
|
|
|
|
maxFeatures: 100000000, |
|
|
|
|
|
queryParameter: { |
|
|
|
|
|
attributeFilter: filter |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
if (serviceToken) { |
|
|
|
|
|
params.k = serviceToken; |
|
|
|
|
|
} |
|
|
const result = await axios.post( |
|
|
const result = await axios.post( |
|
|
queryUrl, |
|
|
queryUrl, |
|
|
JSON.stringify({ |
|
|
JSON.stringify(params), |
|
|
getFeatureMode: 'SQL', |
|
|
|
|
|
datasetNames: [datasourceName], |
|
|
|
|
|
maxFeatures: 100000000, |
|
|
|
|
|
queryParameter: { |
|
|
|
|
|
attributeFilter: filter |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
{ |
|
|
{ |
|
|
headers: { |
|
|
headers: { |
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' |
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' |
|
@ -283,6 +289,7 @@ export function useLayer() { |
|
|
if (!layerType || !(action = layerActions[layerType as string])) return; |
|
|
if (!layerType || !(action = layerActions[layerType as string])) return; |
|
|
let layer: any = await action(layerData); |
|
|
let layer: any = await action(layerData); |
|
|
if (isNeedCluster === '1' && layerData.nameCn === "水库点") { |
|
|
if (isNeedCluster === '1' && layerData.nameCn === "水库点") { |
|
|
|
|
|
let baseUrl = import.meta.env.VITE_BASE_URL; |
|
|
const data = await getFeatures(layerData); |
|
|
const data = await getFeatures(layerData); |
|
|
if (data?.features?.[0]?.geometry?.type === 'Point') { |
|
|
if (data?.features?.[0]?.geometry?.type === 'Point') { |
|
|
let layerConfig = {}; |
|
|
let layerConfig = {}; |
|
@ -298,7 +305,7 @@ export function useLayer() { |
|
|
{ name: "4.0", attr: "image", value: "reservoir_small.png" }, |
|
|
{ name: "4.0", attr: "image", value: "reservoir_small.png" }, |
|
|
{ name: "5.0", attr: "image", value: "reservoir_small.png" }, |
|
|
{ name: "5.0", attr: "image", value: "reservoir_small.png" }, |
|
|
], |
|
|
], |
|
|
image: "reservoir_small.png", |
|
|
image: "map-title-o.png", |
|
|
}; |
|
|
}; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -306,7 +313,7 @@ export function useLayer() { |
|
|
data, |
|
|
data, |
|
|
symbol: { |
|
|
symbol: { |
|
|
type: "billboardP", |
|
|
type: "billboardP", |
|
|
imageProxy: "/src/assets/map/", // 图片代理
|
|
|
imageProxy: `${baseUrl}/img/map/`, // 图片代理
|
|
|
style: { |
|
|
style: { |
|
|
clampToGround: false, |
|
|
clampToGround: false, |
|
|
image: "reservoir_small.png", |
|
|
image: "reservoir_small.png", |
|
@ -359,10 +366,21 @@ export function useLayer() { |
|
|
const { layerType } = data; |
|
|
const { layerType } = data; |
|
|
zoomToLayerActions[layerType as string]?.(data); |
|
|
zoomToLayerActions[layerType as string]?.(data); |
|
|
}; |
|
|
}; |
|
|
|
|
|
const viewerClick = throttle((e) => { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
}, 500); |
|
|
|
|
|
const addViewerMouseClick = () => { |
|
|
|
|
|
window.viewer?.on(SyCim.MouseEventType.MOUSE_MOVE, viewerClick); |
|
|
|
|
|
}; |
|
|
|
|
|
const removeViewerMouseClick = () => { |
|
|
|
|
|
window.viewer?.off(SyCim.MouseEventType.MOUSE_MOVE, viewerClick); |
|
|
|
|
|
}; |
|
|
return { |
|
|
return { |
|
|
addLayer, |
|
|
addLayer, |
|
|
removeLayer, |
|
|
removeLayer, |
|
|
zoomToLayer |
|
|
zoomToLayer, |
|
|
|
|
|
addViewerMouseClick, |
|
|
|
|
|
removeViewerMouseClick |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|