-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cesium2d viewer #7234
base: main
Are you sure you want to change the base?
Cesium2d viewer #7234
Changes from all commits
cd11439
6b967b9
1947592
a106ed2
fab282a
5ff3b14
4c35503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import TerriaViewer from "../ViewModels/TerriaViewer"; | |
|
||
enum ViewerMode { | ||
Cesium = "cesium", | ||
Cesium2D = "cesium2d", | ||
Leaflet = "leaflet" | ||
} | ||
|
||
|
@@ -24,6 +25,12 @@ export const MapViewers = Object.seal({ | |
terrain: false, | ||
label: "settingPanel.viewerModeLabels.Leaflet", | ||
available: true | ||
}, | ||
cesium2d: { | ||
viewerMode: ViewerMode.Cesium2D, | ||
terrain: false, | ||
label: "settingPanel.viewerModeLabels.Leaflet", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other entries have unique labels, so I'm guessing this entry shouldn't use the already used Leaflet-label. |
||
available: true | ||
} | ||
}); | ||
|
||
|
@@ -38,6 +45,9 @@ export function setViewerMode( | |
if (viewerMode === "3d" || viewerMode === "3dsmooth") { | ||
viewer.viewerMode = ViewerMode.Cesium; | ||
viewer.viewerOptions.useTerrain = viewerMode === "3d"; | ||
} else if (viewerMode === "cesium2d") { | ||
viewer.viewerMode = ViewerMode.Cesium2D; | ||
viewer.viewerOptions.useTerrain = false; | ||
} else if (viewerMode === "2d") { | ||
viewer.viewerMode = ViewerMode.Leaflet; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,10 @@ class SettingPanel extends React.Component<PropTypes> { | |
constructor(props: PropTypes) { | ||
super(props); | ||
makeObservable(this); | ||
|
||
Object.entries(MapViewers).forEach(([key, elem]) => { | ||
elem.available = props.terria.configParameters.mapViewers.includes(key); | ||
}); | ||
} | ||
|
||
@observable _hoverBaseMap = null; | ||
|
@@ -168,7 +172,9 @@ class SettingPanel extends React.Component<PropTypes> { | |
2: t("settingPanel.qualityLabels.lowerPerformance") | ||
}; | ||
const currentViewer = | ||
this.props.terria.mainViewer.viewerMode === ViewerMode.Cesium | ||
this.props.terria.mainViewer.viewerMode === ViewerMode.Cesium2D | ||
? ViewerMode.Cesium2D | ||
: this.props.terria.mainViewer.viewerMode === ViewerMode.Cesium | ||
? this.props.terria.mainViewer.viewerOptions.useTerrain | ||
? "3d" | ||
: "3dsmooth" | ||
|
@@ -247,15 +253,17 @@ class SettingPanel extends React.Component<PropTypes> { | |
<Text as="label">{t("settingPanel.mapView")}</Text> | ||
</Box> | ||
<FlexGrid gap={1} elementsNo={3}> | ||
{Object.entries(MapViewers).map(([key, viewerMode]) => ( | ||
<SettingsButton | ||
key={key} | ||
isActive={key === currentViewer} | ||
onClick={(event: any) => this.selectViewer(key as any, event)} | ||
> | ||
<Text mini>{t(viewerMode.label)}</Text> | ||
</SettingsButton> | ||
))} | ||
{Object.entries(MapViewers) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous line contains And even without filtering, why does the previous line not need to be updated to contain 4 since there is one more item in MapViewers in this PR? |
||
.filter(([_, viewerMode]) => viewerMode.available) | ||
.map(([key, viewerMode]) => ( | ||
<SettingsButton | ||
key={key} | ||
isActive={key === currentViewer} | ||
onClick={(event: any) => this.selectViewer(key as any, event)} | ||
> | ||
<Text mini>{t(viewerMode.label)}</Text> | ||
</SettingsButton> | ||
))} | ||
</FlexGrid> | ||
{!!supportsSide && ( | ||
<> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,12 @@ const cesiumFromPromise = computed( | |
{ keepAlive: true } | ||
); | ||
|
||
const cesium2dFromPromise = computed( | ||
() => | ||
fromPromise(import("../Models/Cesium").then((Cesium) => Cesium.default)), | ||
{ keepAlive: true } | ||
); | ||
|
||
// Viewer options. Designed to be easily serialisable | ||
interface ViewerOptions { | ||
useTerrain: boolean; | ||
|
@@ -173,6 +179,8 @@ export default class TerriaViewer { | |
viewerFromPromise = leafletFromPromise.get(); | ||
} else if (this.attached && this.viewerMode === ViewerMode.Cesium) { | ||
viewerFromPromise = cesiumFromPromise.get(); | ||
} else if (this.attached && this.viewerMode === ViewerMode.Cesium2D) { | ||
viewerFromPromise = cesium2dFromPromise.get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To me, the body of |
||
} | ||
return viewerFromPromise; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type says this is an array rather than a list. The JSDoc for the other array-options seems to start with just "The", so "The enabled MapViewers .." in this case.