Skip to content

Commit

Permalink
fix: use overriddenLayers to get infobox on reearth/core (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya01 authored Mar 14, 2023
1 parent 95b3d3a commit c4e9db0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/core/engines/Cesium/Feature/Resource/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ export default function Resource({ isVisible, property, layer, onComputedFeature
}
return;
}
viewer.clock.currentTime = ds.clock.currentTime;
viewer.clock.startTime = ds.clock.startTime;
viewer.clock.stopTime = ds.clock.stopTime;
if (ds.clock) {
viewer.clock.currentTime = ds.clock.currentTime;
viewer.clock.startTime = ds.clock.startTime;
viewer.clock.stopTime = ds.clock.stopTime;
}
},
[updateClock, viewer?.clock],
);
Expand Down
20 changes: 11 additions & 9 deletions src/core/engines/Cesium/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export default ({
}

if (entity) {
const layer = tag?.layerId
? layersRef?.current?.overriddenLayers().find(l => l.id === tag.layerId) ??
layersRef?.current?.findById(tag.layerId)
: undefined;
// Sometimes only featureId is specified, so we need to sync entity tag.
onLayerSelect?.(
tag?.layerId,
Expand All @@ -250,10 +254,7 @@ export default ({
content: getEntityContent(
entity,
cesium.current?.cesiumElement?.clock.currentTime ?? new JulianDate(),
tag?.layerId
? layersRef?.current?.findById(tag.layerId)?.infobox?.property?.default
?.defaultContent
: undefined,
tag?.layerId ? layer?.infobox?.property?.default?.defaultContent : undefined,
),
},
}
Expand Down Expand Up @@ -328,6 +329,10 @@ export default ({

if (target && "id" in target && target.id instanceof Entity && isSelectable(target.id)) {
const tag = getTag(target.id);
const layer = tag?.layerId
? layersRef?.current?.overriddenLayers().find(l => l.id === tag.layerId) ??
layersRef?.current?.findById(tag.layerId)
: undefined;
onLayerSelect?.(
tag?.layerId,
tag?.featureId,
Expand All @@ -338,10 +343,7 @@ export default ({
content: getEntityContent(
target.id,
viewer.clock.currentTime ?? new JulianDate(),
tag?.layerId
? layersRef?.current?.findById(tag.layerId)?.infobox?.property?.default
?.defaultContent
: undefined,
tag?.layerId ? layer?.infobox?.property?.default?.defaultContent : undefined,
),
},
}
Expand Down Expand Up @@ -386,7 +388,7 @@ export default ({

onLayerSelect?.();
},
[onLayerSelect, mouseEventHandles, layersRef, selectedLayerId?.layerId],
[onLayerSelect, mouseEventHandles, layersRef],
);

// E2E test
Expand Down

0 comments on commit c4e9db0

Please sign in to comment.