Closed paragemini closed 2 years ago
For the moment this would require shiny, listening on get_clicked_object()
and filtering data that way.
In a static html document, this will inevitably require javascript. There's currently no way to subscribe to clicks without shiny (not that it's difficult, just haven't exposed a hook for it), but something like this is doable.
const map = rdeck.getWidgetById("my-map");
// not supported yet
map.onClick = ({ layer, object }) => {
if (layer.id !== "source-layer-id") return;
const targetLayer = map.layers.find((layer) => layer.id === "target-layer-id");
if (targetLayer == null) return;
// filter data. how that is done depends on the shape and whether its geojson or tabular
const data = filterDataWithObject(layer.data, object);
// method doesn't exist
map.updateLayer({ ...targetLayer, data });
};
Thank you for this. I will need to learn some JS for this
Rdeck now exposes deck.gl's onClick handler (#73). You can directly assign the handler like this:
const map = rdeck.getWidgetById("my-map");
map.state.deckgl.onClick = (info, event) => { /* do something */ };
Setting a click handler in this way will not affect shiny get_clicked_object()
@anthonynorth thanks for creating a solution. Is it possible if you can show this through a vignette. Would help in understanding for people who dont understand JS.
I understand what you are trying to do, but I am not sure where would this go in the scheme of things. Thank you again for helping out.
Hello - Thanks for the lovely package.
I am trying to make an example like this in the deck.gl examples and trying to mimic the dynamism of arc getting updated when clicking on any other county
https://deck.gl/examples/arc-layer/
If I look at the source code, line 91 specifies the dynamic event happening that needs no server on their side
https://github.com/visgl/deck.gl/blob/8.7-release/examples/website/arc/app.js
While going through documentation of arcMapLayer and GeoJson I couldn't find anything that would let me get access to the object when clicked :
https://anthonynorth.github.io/rdeck/reference/arc_layer.html https://anthonynorth.github.io/rdeck/reference/geojson_layer.html
My question is it possible to make something like this in R Markdown and save it an HTML document ?