Skip to content

Commit

Permalink
Add POC for deck tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed May 30, 2024
1 parent 3fa603e commit ff578b2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/examples/deckgl_layer/airports_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"getPointRadius": "@@=11 - properties.scalerank",
"getFillColor": [200, 0, 80, 180],
"autoHighlight": True,
"pickable": True,
}

deck_arc_layer = {
Expand Down
1 change: 1 addition & 0 deletions docs/examples/deckgl_layer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"getElevationWeight": "@@=SPACES",
"elevationScale": 4,
"cellSize": 200,
"pickable": True,
}

m.add_deck_layers([deck_grid_layer])
Expand Down
6 changes: 3 additions & 3 deletions maplibre/srcjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions srcjs/pymaplibregl.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,28 @@ export default class PyMapLibreGL {
return;
}
const layers = deckLayers.map((deckLayer) =>
this._JSONConverter.convert(deckLayer),
this._JSONConverter.convert(
Object.assign(deckLayer, {
onHover: ({ object }) => console.log(object),
}),
),
);
console.log("layers", layers);
// console.log("deckLayers", layers);

// Just as a POC, Use mustache template, maybe set tooltip via onHover using Popups from maplibregl
function getTooltip({ object }) {
return (
object &&
Object.entries(object)
.map(([k, v]) => `${k}: ${v}`)
.join(", ")
);
}

const deckOverlay = new deck.MapboxOverlay({
interleaved: true,
layers: layers,
getTooltip,
});
this._map.addControl(deckOverlay);
}
Expand Down

0 comments on commit ff578b2

Please sign in to comment.