-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dynamic-render): ✨ geojson不展示子节点例子
- Loading branch information
Showing
2 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
@@ -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' | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
@@ -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] | ||
|
@@ -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], | ||
|