I'm finding Mapdeck to be a really cool alternative mapping method when working with large datasets in r shiny. However I'm finding it difficult to pass in multiple datasets in order to expand the complexity of the resulting map.
For Example: I'm trying to populate the tooltip to create a popup with 'two' items by pulling in information from a second data frame (to illustrate a 1-to-many relationship). But I can't get it to work. Any thoughts?
Data sample
Map_DF <- data.frame("Point_ID" = 1:3, "Latitude" = c(38.05, 39.08, 40.05), "Longitude" = c(-107.00, -107.05, -108.00))
PointUse_DF <- data.frame("Point_ID" = c(1, 1, 2, 2, 3), "PointUse" = c("farm", "house", "farm", "house", "farm"))
The Code.
# ################################################################################################
# ################################################################################################
# # Sec 1a. Needed Libaries & Input Files
library(shiny)
library(shinydashboard)
library(mapdeck)
library(dplyr)
################################################################################################
################################################################################################
#UI
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
mapdeckOutput(outputId = 'mapA')
)
)
################################################################################################
################################################################################################
server <- function(input, output) {
##The MapDeck Token
key <- '## put your own token here ##'
set_token(key) ## set your access token
### The Map
output$mapA <- renderMapdeck({
mapdeck() %>%
add_scatterplot(
data = Map_DF,
lat = "Latitude",
lon = "Longitude",
layer_id = 'Point_ID',
tooltip = c("Point_ID",
PointUse_DF$PointUse[Map_DF$Point_ID] # the idea of passing in a a key and returning multiple items
)
)
})
}
################################################################################################
################################################################################################
shinyApp(ui = ui, server = server)