Skip to content

Commit 8ae5c8a

Browse files
committed
Partial fixes for google tiles
1 parent faab435 commit 8ae5c8a

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

deps/cesium-viewer

packages/globe-dev/src/cesium-view.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ function buildSatelliteLayer({ accessToken }) {
4141
return provider;
4242
}
4343

44-
function CesiumView({ style, showGeology, accessToken, useGoogleTiles = false, ...rest }) {
45-
const terrainProvider = useRef(
44+
function CesiumView({
45+
style,
46+
showGeology,
47+
accessToken,
48+
showGoogleTiles,
49+
googleMapsAPIKey,
50+
...rest
51+
}) {
52+
const terrainProvider: any = useRef(
4653
new TerrainProvider({
4754
hasVertexNormals: false,
4855
hasWaterMask: false,
@@ -54,11 +61,12 @@ function CesiumView({ style, showGeology, accessToken, useGoogleTiles = false, .
5461
})
5562
);
5663

57-
if (useGoogleTiles) {
64+
if (showGoogleTiles) {
65+
// @ts-ignore
5866
return h(
5967
CesiumViewer,
6068
{
61-
terrainProvider: null,
69+
terrainProvider: terrainProvider.current,
6270
displayQuality: DisplayQuality.High,
6371
fogDensity: 0.0002,
6472
//skyBox: true,
@@ -68,12 +76,13 @@ function CesiumView({ style, showGeology, accessToken, useGoogleTiles = false, .
6876
},
6977
[
7078
h(GooglePhotorealistic3DTileset, {
71-
googleMapsAPIKey: import.meta.env.VITE_GOOGLE_MAPS_API_KEY,
79+
googleMapsAPIKey,
7280
}),
7381
]
7482
);
7583
}
7684

85+
// @ts-ignore
7786
return h(
7887
CesiumViewer,
7988
{
@@ -86,9 +95,13 @@ function CesiumView({ style, showGeology, accessToken, useGoogleTiles = false, .
8695
...rest,
8796
},
8897
[
89-
h(SatelliteLayer, { accessToken }),
90-
h(GeologyLayer, { alpha: 0.3, show: showGeology }),
98+
h(SatelliteLayer, { accessToken, show: !showGoogleTiles }),
99+
h(GeologyLayer, { alpha: 0.3, show: showGeology && !showGoogleTiles }),
91100
h(MapboxLogo),
101+
// h(GooglePhotorealistic3DTileset, {
102+
// googleMapsAPIKey: import.meta.env.VITE_GOOGLE_MAPS_API_KEY,
103+
// show: showGoogleTiles,
104+
// }),
92105
]
93106
);
94107
}

packages/globe-dev/src/index.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ import Map from "./map-comparison";
2727

2828
const h = hyper.styled(styles);
2929

30-
function VisControl({ show, setShown, name }) {
30+
function VisControl({ show, setShown, name, children }) {
3131
const className = show ? "active" : "";
32-
return h(
33-
"li",
32+
return h("li.vis-control", [
3433
h(
3534
"a",
3635
{
@@ -40,8 +39,9 @@ function VisControl({ show, setShown, name }) {
4039
},
4140
},
4241
[show ? "Hide" : "Show", " ", name]
43-
)
44-
);
42+
),
43+
children,
44+
]);
4545
}
4646

4747
function getStartingPosition(): MapPosition {
@@ -75,17 +75,20 @@ function App({ accessToken }) {
7575
const style = "mapbox://styles/jczaplewski/cklb8aopu2cnv18mpxwfn7c9n";
7676
const [showWireframe, setShowWireframe] = useState(false);
7777
const [showInspector, setShowInspector] = useState(false);
78-
const [useGoogleTiles, setUseGoogleTiles] = useState(false);
78+
const [showGoogleTiles, setShowGoogleTiles] = useState(false);
7979
const [showMapbox, setShowMapbox] = useState(false);
8080
const [showGeology, setShowGeology] = useState(false);
8181
const [position, setPosition] = useState<MapPosition>(
8282
initialPosition.current
8383
);
8484

85+
const googleMapsAPIKey = import.meta.env.VITE_GOOGLE_MAPS_API_KEY;
86+
8587
const queryString = useRef<object>({});
8688

8789
useEffect(() => {
8890
let hashData = {};
91+
console.log("Updated position");
8992
applyMapPositionToHash(hashData, position);
9093
queryString.current = buildQueryString(hashData);
9194
setHashString(hashData);
@@ -105,6 +108,7 @@ function App({ accessToken }) {
105108
}
106109

107110
const onViewChange = useCallback((cpos: CameraParams) => {
111+
console.log("View changed");
108112
const { camera } = cpos;
109113
setPosition({
110114
camera: {
@@ -138,8 +142,8 @@ function App({ accessToken }) {
138142
}),
139143
h(VisControl, {
140144
name: "Google tiles",
141-
show: useGoogleTiles,
142-
setShown: setUseGoogleTiles,
145+
show: showGoogleTiles,
146+
setShown: setShowGoogleTiles,
143147
}),
144148
h(VisControl, {
145149
name: "geology",
@@ -159,10 +163,11 @@ function App({ accessToken }) {
159163
showWireframe,
160164
showInspector,
161165
showGeology,
162-
useGoogleTiles,
166+
showGoogleTiles,
163167
highResolution: true,
164168
displayQuality: DisplayQuality.High,
165169
onViewChange,
170+
googleMapsAPIKey,
166171
}),
167172
]),
168173
h.if(showMapbox)("div.map-panel", [

0 commit comments

Comments
 (0)