All Questions
1,955
questions
72
votes
8
answers
27k
views
How to get Leaflet for R use 100% of Shiny dashboard height
I am in the process of creating a Shiny dashboard application, where the dashboard body is supposed to show some maps. So far no problem to get the map expand over the entire width of the body, but it'...
53
votes
2
answers
47k
views
How to save Leaflet in R map as png or jpg file?
I'm using Leaflet package to create maps in R. It works perfectly. I can export maps in R with simply Export, but I need to export maps from script in R. My simple code is:
png("test_png.png")
(m <...
49
votes
6
answers
41k
views
Saving leaflet output as html
I am using RStudio to create some some leaflet images.
I would like to be able to save the output as an HTML so that it can be emailed and others can view it.
Below is some sample R code which was ...
31
votes
5
answers
29k
views
How Do I connect two coordinates with a line using Leaflet in R
I am trying to use Leaflet package in R to draw a amp and connect the markers given the latitude and longitude information in the table below.
| Observation | InitialLat | InitialLong | NewLat ...
30
votes
3
answers
18k
views
R and Leaflet: How to arrange label text across multiple lines
Suppose you have the following data frame:
cities = data.frame( name = c('Madrid','Barcelona','Sevilla'),
country = c('Spain','Spain','Spain'),
region = c('Comunidad ...
26
votes
4
answers
15k
views
Adjust size of leaflet map in rmarkdown html
I'd like to change the height and width of leaflet map outputs in html document. Is there a simple way to do this in R markdown without getting into whole CSS business?
```{r}
library(leaflet)
...
25
votes
2
answers
18k
views
Popup when hover with leaflet in R?
My leaflet map looks something like this:
library(sp)
library(leaflet)
circleFun <- function(center = c(0,0),diameter = 1, npoints = 100){
r = diameter / 2
tt <- seq(0,2*pi,length.out = ...
24
votes
1
answer
3k
views
Is it possible to switch between multiple legends when switching between base groups?
I am visualizing some vector data using leaflet in r which has multiple non-spatial variables that a user might be interested in. I want to allow the user to select one variable that will determine ...
23
votes
5
answers
60k
views
Change color of leaflet marker
Is there anyway to change the color of leaflet marker base on the value of some variable. In the following map, for example, I wish to assign marker color based on mag variable:
library(leaflet)
...
21
votes
1
answer
14k
views
R leaflet zoomControl option
I'm building a map tool in R using leaflet, and I would like to restrict the zoom to a certain area, but the setMaxBounds function doesn't seem to have any effect.
library(dplyr)
library(leaflet)
...
20
votes
2
answers
28k
views
leaflet with R: add text labels
This code is taken from this page:
library(leaflet)
leaflet(data = quakes[1:20,]) %>% addTiles() %>%
addMarkers(~long, ~lat, popup = ~as.character(mag))
Instead of markers, is there any way ...
19
votes
2
answers
32k
views
R: Add title to Leaflet map
I'd like to add a title to the whole map (different from the legend title: addLegend(..., title = "", ...): by "title", I mean an overlaid map component that stays in place while the map is moved (...
19
votes
1
answer
11k
views
How to get the zoom level from the leaflet map in R/shiny?
I create a map using leaflet package in Shiny which have a selectInput to allow user to select from a site list. The site list also adds into leaflet as markers.
When user selects a new site, I want ...
19
votes
2
answers
9k
views
R: Maps with Time Slider?
Is there a way to implement a time slider for Leaflet or any other interactive map library in R? I have data arranged in a time series, and would like to integrate that into a "motion" map where the ...
18
votes
2
answers
9k
views
How to display (advanced) customed popups for leaflet in Shiny?
I am using R shiny to build web applications, and some of them are leveraging the great leaflet features.
I would like to create a customed and advanced popup, but I do not know how to proceed.
You ...