| | |
| | | import LayerControl from './LayerControl.vue'; |
| | | import PanelTool from './panelTool/index.vue'; |
| | | import { |
| | | getMapDrawStyles, |
| | | getMapLayerGroupList, |
| | | getMapLayersByPost, |
| | | getMapThemeList, |
| | |
| | | }), |
| | | } |
| | | ); |
| | | |
| | | |
| | | const colsArray = computed(() => { |
| | | return props.data.cols ?? []; |
| | |
| | | |
| | | const maxResolution = 1; |
| | | |
| | | const getText = function (feature, resolution) { |
| | | const oname = feature.get('oname'); |
| | | let text = `first-${oname[0]}`; |
| | | const getText = function (textContent, resolution) { |
| | | let text = `${textContent}`; |
| | | if (resolution > maxResolution) { |
| | | text = ''; |
| | | } |
| | |
| | | |
| | | return text; |
| | | }; |
| | | const createTextStyle = (feature, resolution) => { |
| | | const createTextStyle = (textContent, resolution) => { |
| | | return new Style({ |
| | | text: new Text({ |
| | | text: getText(feature, resolution), |
| | | text: getText(textContent, resolution), |
| | | font: '14px Arial', |
| | | fill: new Fill({ color: '#000' }), |
| | | stroke: new Stroke({ color: '#fff', width: 2 }), |
| | |
| | | }; |
| | | |
| | | const styleMap: Record<string, Record<string, Style>> = { |
| | | junction: {}, |
| | | pipe: {}, |
| | | point: {}, |
| | | line: {}, |
| | | polygon: {}, |
| | | }; |
| | | /** @description 已经做的layer,后续全部做好,可以不做判断 */ |
| | |
| | | switch (shape) { |
| | | case 'Point': |
| | | const pSize = feature.get('psize'); |
| | | if (!pSize) return null; |
| | | |
| | | const pcolor = feature.get('pcolor'); |
| | | const pkey = `${pSize}_${pcolor}`; |
| | | |
| | | if (!styleMap.junction[pkey]) { |
| | | styleMap.junction[pkey] = new Style({ |
| | | image: new Circle({ |
| | | radius: pSize, |
| | | fill: new Fill({ color: `#${pcolor}` }), |
| | | }), |
| | | const pstyle = feature.get('pstyle'); |
| | | const pointStyle = olMap.value.getPointStyles({ |
| | | size: pSize, |
| | | color: pcolor, |
| | | style: pstyle, |
| | | }); |
| | | } |
| | | |
| | | // const textStyle = createTextStyle(feature, resolution); |
| | | styles.push(styleMap.junction[pkey]); |
| | | styles.push(pointStyle); |
| | | break; |
| | | case 'LineString': |
| | | const lSize = feature.get('lsize'); |
| | | if (!lSize) return null; |
| | | const lColor = feature.get('lcolor'); |
| | | const lKey = `${lSize}_${lColor}`; |
| | | if (!styleMap.pipe[lKey]) { |
| | | styleMap.pipe[lKey] = new Style({ |
| | | // image: new Circle({ |
| | | // radius: lsize, |
| | | // fill: new Fill({ color: `#${color}` }), |
| | | // }), |
| | | stroke: new Stroke({ |
| | | color: `#${lColor}`, |
| | | width: lSize, |
| | | }), |
| | | const lstyle = feature.get('lstyle'); |
| | | |
| | | const lineStyle = olMap.value.getLineStyles({ |
| | | lsize: lSize, |
| | | lcolor: lColor, |
| | | lstyle: lstyle, |
| | | }); |
| | | } |
| | | styles.push(styleMap.pipe[lKey]); |
| | | styles.push(...lineStyle); |
| | | break; |
| | | case 'Polygon': |
| | | break; |
| | |
| | | break; |
| | | } |
| | | |
| | | const otype = feature.get('otype'); |
| | | // switch (otype) { |
| | | // case 'WDM_JUNCTIONS': |
| | | // const textStyle = createTextStyle(feature, resolution); |
| | |
| | | // } |
| | | //#region ====================== 添加标注 ====================== |
| | | const tString = feature.get('tstring'); |
| | | if (tString) { |
| | | const textStyle = createTextStyle(feature, resolution); |
| | | styles.push(textStyle); |
| | | |
| | | const tStringStyle = olMap.value.getLabelStyles({ |
| | | textContent: tString, |
| | | resolution, |
| | | }); |
| | | if (tStringStyle) { |
| | | styles.push(tStringStyle); |
| | | } |
| | | //#endregion |
| | | |
| | |
| | | return groupList; |
| | | }; |
| | | |
| | | const getDrawStyles = async () => { |
| | | const res = await getMapDrawStyles(); |
| | | const styleList = res?.values ?? []; |
| | | olMap.value.setDrawStyles(styleList); |
| | | }; |
| | | |
| | | const getThemeList = async () => { |
| | | const res = await getMapThemeList(); |
| | |
| | | type: 'theme', |
| | | activeTheme: null, |
| | | legends: null, |
| | | |
| | | }; |
| | | mapGroupItem.children.push(data); |
| | | return preVal; |
| | |
| | | olMap.value.setAllThemes(themeTreeData); |
| | | }; |
| | | const initVectorTileLayer = async () => { |
| | | await getDrawStyles(); |
| | | const res = await getMapLayersByPost(); |
| | | const layers = reverse(res?.layers ?? []); |
| | | if (layers.length === 0) return; |
| | |
| | | |
| | | layer.set('originStyle', styleFunc); |
| | | layerModels.push(layer); |
| | | |
| | | } |
| | | getGroupList().then((groupList) => { |
| | | olMap.value.setAllLayers(layerModels, layers, groupList); |