This R package makes it easy to integrate and control the open-source JavaScript Leaflet software in R.
Questions tagged [r-leaflet]
499 questions
30
votes
5 answers
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 | NewLong |
…

maluwalmk
- 337
- 1
- 3
- 8
24
votes
1 answer
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 the color of the features. I accomplish this with…

Joe
- 3,831
- 4
- 28
- 44
23
votes
2 answers
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 = npoints)
xx <- center[1] + r * cos(tt)
yy <- center[2]…

Ignacio
- 7,646
- 16
- 60
- 113
18
votes
2 answers
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 (unlike an overlaid image).
Is that an option in…

YGS
- 623
- 1
- 6
- 16
16
votes
1 answer
Optimising Shiny + Leaflet performance for detailed maps with many 'layers'
I want to make a Shiny app where the colouring of a choropleth is based on a numeric value of one of many possible quantitative variables that a user can select from. In simple cases, this is straightforward, but I'm unsure of the best practices…

dcl
- 929
- 1
- 10
- 22
15
votes
1 answer
Can't suppress messages in blogdown/knitr
Here is a blog post created with blogdown
The R chunk of code begins with
```{r, echo = FALSE, message = FALSE, warning = FALSE}
However, three messages appear each time I read a shapefile using sf::st_read
How do I prevent these messages from…

ixodid
- 2,180
- 1
- 19
- 46
13
votes
1 answer
How to add labels on top of polygons in leaflet
I am working with the leaflet R package. I have a zoning system made of polygons and I'd like to lay their IDs on top of them. Below is an illustration (with another software) of my objective.
Thanks for your suggestions!

wrocg
- 145
- 1
- 1
- 4
12
votes
2 answers
Cache or pre render leaflet map in shiny app
I am trying to map ~8000 polygons using leaflet and run into performance issues.
As I am using the map within a shiny app, I was wondering if its possible to somehow cache or pre-render the map.
Note that in my case, I have different layers of…

David
- 9,216
- 4
- 45
- 78
12
votes
1 answer
How to add a text on a leaflet map?
Each day I need to draw a path on a map and add a text like 4, 5 or 8 min. indicating how long it takes by car from the starting point to the destination (see the figure below). I thought it would be helpful to create a Shiny app using Leaflet in R…

BRCN
- 635
- 1
- 12
- 26
12
votes
1 answer
Shiny - how to highlight an object on a leaflet map when selecting a record in a datatable?
Is there a way to highlight a marker or polyline on a leaflet map when selecting (clicking on) the corresponding record in a datatable?
I looked at these questions/threads:
selecting a marker on leaflet, from a DT row click and vice versa - no…

M_M
- 899
- 8
- 21
10
votes
1 answer
Plotting sf-type object in leaflet [r]
I would like to ask how to plot sf object in leaflet from leaflet package I am aware about mapview package that can plot it however I prefer using lealfet package.
I provided example down…

Petr
- 1,606
- 2
- 14
- 39
8
votes
1 answer
Select multiple items using map_click in leaflet, linked to selectizeInput() in shiny app (R)
I would like to create a leaflet map where you can select multiple polygons and this will update the selectizeInput() in a shiny app. This would including removing a selected polygon, when it is removed in the selectizeInput().
I have slightly…

william3031
- 1,653
- 1
- 18
- 39
7
votes
2 answers
How can I plot individual data points in a map using R/ leaflet?
I am trying to show the individual points in a given place, like a map equivalent of dot plot. I tried with leaflet library in R, but I am only able to map the size of the marker to the continuous variable. Is it possible to map the individual data…

karthik2k2
- 71
- 1
- 3
7
votes
0 answers
Increase size of rleaflet map in Jupyter Lab display (R in Jupyter)
When using R and rleaflet in a Jupyter Lab Notebook. My output map is short and wide with a vertical scroll box, and I can find no means of increasing it's height.
# Code to reproduce
library(leaflet)
m = leaflet() %>% addTiles()
m
results in:

Colin Talbert
- 454
- 6
- 20
7
votes
1 answer
R Shiny map search input box
In google maps, the search input box auto completes addresses as a user types. Is there a way to do this in R Shiny with access to the autocomplete value in order to use with a mapping package?
There is a javascript method here. I've tried to use…

Vlad
- 3,058
- 4
- 25
- 53