Skip to content

Commit e643a0b

Browse files
committed
Add tooltip to google 3d tiles example
This demonstrates the working picking on layers draped over terrain cover.
1 parent f83b5ff commit e643a0b

File tree

1 file changed

+14
-1
lines changed
  • examples/website/google-3d-tiles

1 file changed

+14
-1
lines changed

examples/website/google-3d-tiles/app.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ const INITIAL_VIEW_STATE = {
3232
const BUILDING_DATA =
3333
'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/google-3d-tiles/buildings.geojson';
3434

35+
function getTooltip({object}) {
36+
return (
37+
object && {
38+
html: `\
39+
<div><b>Distance to nearest tree</b></div>
40+
<div>${object.properties.distance_to_nearest_tree} / parcel</div>
41+
`
42+
}
43+
);
44+
}
45+
3546
export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
3647
const [credits, setCredits] = useState('');
3748

@@ -64,7 +75,8 @@ export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
6475
getFillColor: ({properties}) => colorScale(properties.distance_to_nearest_tree),
6576
opacity,
6677
getFilterValue: f => f.properties.distance_to_nearest_tree,
67-
filterRange: [distance, 500]
78+
filterRange: [distance, 500],
79+
pickable: true
6880
})
6981
];
7082

@@ -75,6 +87,7 @@ export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
7587
initialViewState={INITIAL_VIEW_STATE}
7688
controller={{touchRotate: true, inertia: 250}}
7789
layers={layers}
90+
getTooltip={getTooltip}
7891
/>
7992
<div
8093
style={{position: 'absolute', left: '8px', bottom: '4px', color: 'white', fontSize: '10px'}}

0 commit comments

Comments
 (0)