Having checked multiple maps packages, I think that the best shiny option is leaflet. It's interactive (you can play with the map) and the syntax is really simple, and looks a lot like dplyr.
Here's a very simple example which shows markers on a map and text (id) above them
library(leaflet)
dataset = data.frame(lon = rnorm(20,34.9,0.01),lat = rnorm(20,32.15,0.01),id = 1:20)
map <- leaflet(data = dataset) %>%
addTiles() %>%
addMarkers(label = ~as.character(id),
labelOptions = labelOptions(noHide = T, direction = 'top', textOnly = T))
print(map)
This is a full shiny app that displays points on a map. You could extend it to use your own data, add tooltips and legends to show IDs and additional metadata per point.
library(shiny)
library(leaflet)
r_colors <- rgb(t(col2rgb(colors()) / 255))
names(r_colors) <- colors()
ui <- fluidPage(
leafletOutput("mymap"),
p(),
actionButton("recalc", "New points")
)
server <- function(input, output, session) {
points <- eventReactive(input$recalc, {
cbind(rnorm(40) * 2 + 13, rnorm(40) + 48)
}, ignoreNULL = FALSE)
output$mymap <- renderLeaflet({
leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite,
options = providerTileOptions(noWrap = TRUE)
) %>%
addMarkers(data = points())
})
}
shinyApp(ui, server)
source for 2nd example:
https://rstudio.github.io/leaflet/shiny.html
More about leaflet:
https://rstudio.github.io/leaflet/
On Sunday, March 4, 2018 at 8:58:45 PM UTC+2, Lior Smadja wrote: