Geographic Information Systems Asked by Michael Šòdéké on March 21, 2021
If I build with R Markdown
in SublimeText 3, an index.html
file is generated. If I then open this .html
file in either Firefox, Chrome, Brave, etc, the map does not render. For example:
However, If I switch to my Windows terminal and load R
, then use rmarkdown::run()
, the map generates in either browser of choice. For instance:
flexdashboard
with shiny
integration---
title: "COVID-19 Tracker"
date: "`r Sys.Date()`"
fontsize: 9pt
fontfamily: Segoe UI
output: flexdashboard::flex_dashboard
runtime: shiny
---
suppressMessages( require(dplyr) )
suppressMessages( require(tidyr) )
suppressMessages( require(flexdashboard) )
suppressMessages( require(leaflet) )
suppressMessages( require(maps) )
suppressMessages( require(mapdata) )
suppressMessages( require(shiny) )
suppressMessages( require(htmltools) )
suppressMessages( require(htmlwidgets) )
cntry <- map("world2Hires",fill=F,plot=F)$names[1:100]
cntry <- cntry[order(cntry)]
getBounds <- function(vec=NULL)
{
lng1 <- rep(0,length(vec))
lat1 <- rep(0,length(vec))
lng2 <- rep(0,length(vec))
lat2 <- rep(0,length(vec))
for (i in 1:length(vec))
{
lat1[i] <- map("world2Hires",fill=F,region=vec[i],plot=F)$range[3] %>% round(5)
lng2[i] <- map("world2Hires",fill=F,region=vec[i],plot=F)$range[2] %>% round(5)
lat2[i] <- map("world2Hires",fill=F,region=vec[i],plot=F)$range[4] %>% round(5)
lng2[i] <- map("world2Hires",fill=F,region=vec[i],plot=F)$range[1] %>% round(5)
}
cbind(lng1,lat1,lng2,lat2)
}
location <- getBounds(vec=cntry)
df1 <- data.frame(cntry,location)
Column {.sidebar}
--------------------------------------------------
### Epicenter Region
# https://community.rstudio.com/t/rstudio-connect-interactive-markdown-with-shiny-error-path-for-html-dependency-not-provided/7263/11
selectInput("loc",
label="Select Region:",
selectize=FALSE,
choices=df1[,1],
selected=df1[19,1])
Column
--------------------------------------------------
### COVID-19 Epicenters
renderLeaflet({
leaflet() %>% addTiles() %>%
# add tile theme layer
addProviderTiles(providers$CartoDB.Positron) %>%
# add bounds
fitBounds(lng1=map("world2Hires",fill=F,region=input$loc,plot=F)$range[1],
lat1=map("world2Hires",fill=F,region=input$loc,plot=F)$range[3],
lng2=map("world2Hires",fill=F,region=input$loc,plot=F)$range[2],
lat2=map("world2Hires",fill=F,region=input$loc,plot=F)$range[4])
})
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP