Create Interactive Web Maps with the 'JavaScript Datamaps' Library

Easily create interactive choropleth maps then add bubbles and arcs by coordinates or region name. These maps can be used directly from the console, from 'RStudio', in 'Shiny' apps and 'R Markdown' documents. 'Shiny' proxies allow to interactively add arcs and bubbles, change choropleth values, or change labels.


Travis-CI Build Status AppVeyor Build Status CRAN CRAN_Status_Badge

proxies

R htmlwidget for datamaps, plot choropleth, overlay arcs and bubbles, customise options, easily interact with Shiny proxies.

Installation

# CRAN release
install.packages("datamaps")
 
# Development version
devtools::install_github("JohnCoene/datamaps")

Development version includes 2 plugins, add_icons and add_markers.

Info

  • See website for demos.
  • Includes proxies to update the visualisation without re-drawing entire map.
  • See NEWS.md for new features and bug fixes

Shiny Proxies

  • update_bubbles - update bubbles.
  • update_choropleth - update choropleth values.
  • update_labels - update labels.
  • update_legend - update the legend.
  • update_arcs - update arcs by coordinates.
  • update_arcs_name - update arcs by name.
  • delete_map - delete the map.

Examples

Example proxy.

demo

library(shiny)
 
ui <- fluidPage(
 
  textInput(
    "from",
    "Origin",
    value = "USA"
  ),
  textInput(
    "to",
    "Destination",
    value = "RUS"
  ),
  actionButton(
    "submit",
    "Draw arc"
  ),
  datamapsOutput("map")
)
 
server <- function(input, output){
 
  arc <- reactive({
    data.frame(from = input$from, to = input$to)
  })
 
 output$map <- renderDatamaps({
   datamaps()
 })
 
 observeEvent(input$submit, {
   datamapsProxy("map") %>%
     add_data(arc()) %>%
     update_arcs_name(from, to)
 })
 
}
 
shinyApp(ui, server)
}

News

datamaps 0.0.3

  • Support for icons and marker plugins added.
  • longitude and latitude arguments renamed to lon and lat respectively.

datamaps 0.0.2

  • Better shiny reactivity
  • Resizing - datamaps init default responsive = TRUE and width, height to 100%
  • Bug where the map would get redrawn on input change in Shiny fixed.
  • Fixed shiny bug where map would get redrawn instead of updated.
  • Added support for custom topo.json, see set_projection

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("datamaps")

0.0.3 by John Coene, 10 months ago


http://datamaps.john-coene.com


Report a bug at https://github.com/JohnCoene/datamaps/issues


Browse source code at https://github.com/cran/datamaps


Authors: John Coene [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports htmlwidgets, magrittr

Suggests shiny, knitr, rmarkdown, RColorBrewer, countrycode, dplyr


See at CRAN