Skip to content

Commit

Permalink
feat(dynamic-render): ✨ geojson不展示子节点例子
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed May 28, 2024
1 parent 9bbc704 commit a943775
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
35 changes: 33 additions & 2 deletions src/api/modules/tree-data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2022-07-21 17:27:55
* @LastEditTime: 2022-09-12 23:49:12
* @LastEditors: zouyaoji
* @LastEditTime: 2024-05-28 10:58:05
* @LastEditors: zouyaoji [email protected]
* @Description:
* @FilePath: \vue-cesium-demo\src\api\modules\tree-data.ts
*/
Expand Down Expand Up @@ -279,6 +279,37 @@ export default [
}
}
]
},
{
id: uuidv4(),
name: 'GeoJSON',
icon: '',
checked: false,
expanded: false,
renderingType: 'geojson',
children: [
{
type: 'Feature',
properties: {
id: uuidv4(),
checked: false,
name: '水系',
props: {
geojson: {
strokeWidth: 5,
stroke: '#ffc107',
fill: 'transparent',
show: false,
data: `${import.meta.env.BASE_URL}datas/work-bench/水系.json`
}
}
},
geometry: {
coordinates: [108.965836, 34.225607],
type: 'Point'
}
}
]
}
]
}
Expand Down
37 changes: 28 additions & 9 deletions src/utils/render-data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-10-28 10:19:54
* @LastEditTime: 2022-10-20 01:18:16
* @LastEditors: zouyaoji
* @LastEditTime: 2024-05-28 10:56:31
* @LastEditors: zouyaoji [email protected]
* @Description:
* @FilePath: \vue-cesium-demo\src\utils\render-data.ts
*/
Expand Down Expand Up @@ -137,8 +137,8 @@ export function highlightRenderData(
selectedFeatureProps && isPlainObject(selectedFeatureProps)
? selectedFeatureProps
: selectedFeatureProps
? JSON.parse(selectedFeatureProps)
: {}
? JSON.parse(selectedFeatureProps)
: {}

const props = renderingApi === 'primitive' ? model : model[renderingType]
const selectedRenderProps = selectedProps?.[renderingType]
Expand Down Expand Up @@ -714,19 +714,38 @@ const addRenderDataset = (dataset: VcDataset, page: string, type: string, render
dataset.props && isPlainObject(dataset?.props)
? dataset?.props
: dataset.props
? JSON.parse(dataset?.props)
: {}
? JSON.parse(dataset?.props)
: {}
const featureProps =
feature.properties?.props && isPlainObject(feature.properties?.props)
? feature.properties?.props
: feature.properties.props
? JSON.parse(feature.properties?.props)
: {}
? JSON.parse(feature.properties?.props)
: {}

// 优先取 feature 上的 props 参数
const props = Object.assign({}, datasetProps, featureProps)

if (dataset.renderingType === 'tileset') {
if (dataset.renderingType === 'geojson') {
const vcProps = Object.assign(
{},
props[dataset.renderingType],
feature.properties?.props?.[dataset.renderingType]
)

feature.properties.actualRenderingType = dataset.renderingType
renderData.datasets.push({
cmpName: 'VcDatasourceGeojson',
props: {
...vcProps,
show: toRef(feature.properties, 'checked'),
onReady: (e: VcReadyObject) => {
resolve(e)
}
} as VcDatasourceGeojsonProps,
feature
})
} else if (dataset.renderingType === 'tileset') {
const vcProps = Object.assign(
{},
props[dataset.renderingType],
Expand Down

0 comments on commit a943775

Please sign in to comment.