-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discrepancy between point ID and indexing #352
Comments
Technically this is the intended behaviour as the index is used/returned in the var eventInfo = {
index: info.index,
color: info.color,
object: info.object,
layerId: info.layer_id,
lat: info.coordinate[1], // deck.gl 8.4 - https://deck.gl/docs/upgrade-guide#upgrading-from-deckgl-v83-to-v84
lon: info.coordinate[0]
};
eventInfo = JSON.stringify( eventInfo );
Shiny.onInputChange(map_id + "_" + layer + "_click", eventInfo); I think the actual issue is the But thanks for bringing this up; the documentation certainly needs to be clearer. |
Good, interesting. I got mixed up between the different output of the onClick event depending on the layers used. library(mapdeck)
library(shiny)
sf <- geojsonsf::geojson_sf("https://symbolixau.github.io/data/geojson/SA2_2016_VIC.json")
ui <- fluidPage(
mapdeckOutput("map"),
htmlOutput("selection")
)
server <- function(input, output, session) {
# Map
output$map <- renderMapdeck(mapdeck() |>
add_polygon(
data = sf,
id = "SA2_MAIN16",
tooltip = "SA2_MAIN16"))
# Selection
select_id <- eventReactive(input$map_polygon_click, {
jsonlite::fromJSON(input$map_polygon_click)$object$properties$id
})
output$selection <- renderText(paste("Selected output: ", select_id()))
}
shinyApp(ui = ui, server = server) A click on any polygon return its id (its SA2_MAIN16 value in this example). Reclicking on the same polygon then returns NULL, signaling a deselection. The same functionality would be interesting for point data! |
Describe the bug
Within shiny, when a point is clicked on a scatterplot, it retrieves the wrong id supplied through add_scatterplot. It seems it is retrieving the row number -1.
To Reproduce
Expected behaviour
That the
jsonlite::fromJSON(input$map_scatterplot_click)$index
returns the supplied id (inadd_scatterplot
) of the point clicked on.Screenshots
![image](https://user-images.githubusercontent.com/64483932/150398838-495f82e6-c515-4783-a7f3-532a3c62e0ba.png)
Versions
0.3.4
The text was updated successfully, but these errors were encountered: