How to add legend or any text on the map in leaflet?

0 votes
I'm new to leaflet and working on leaflet. I want to add legend or a text indicating which color and popup labels on the top right corner of the screen. Can anyone help me?
Sep 18 in Data Analytics by anonymous
• 32,260 points
78 views

1 answer to this question.

0 votes

See below example,

> p = colorFactor(palette = c("white","green","blue"),domain = c("Office","college","home"),ordered = T)
> my_adds <- leaflet() %>% addTiles() %>% addCircleMarkers(lng=75.6944, lat=11.9811,popup = "My Office",color = "white") %>% addCircleMarkers(lng=77.7141, lat=12.9675,popup = "My college",color = "green") %>% addCircleMarkers(lng=77.669907, lat=13.0118285,popup = "My Home") %>% addLegend(position = "topright",pal = p, values = c("office","home","college"),title = "Address")
> my_adds

answered Oct 28 by anonymous
• 32,260 points

Related Questions In Data Analytics

0 votes
1 answer

How to add only label or popup withpout markers in a map?

Hi, @ch Use addLabelOnlyMarkers( ) to add labels ...READ MORE

answered Sep 23 in Data Analytics by anonymous
• 3,290 points
103 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
184 views
0 votes
0 answers

How to add color legend for box plots in R?

How to add color legend for box ...READ MORE

Jul 3 in Data Analytics by keerthi
28 views
0 votes
0 answers

Any suggestions on how to perform multivariate analysis of fields in R using plots?

Any suggestions on how to perform multivariate ...READ MORE

Jul 22 in Data Analytics by sindhu
29 views
0 votes
1 answer

plot map points from a dataframe

Hi Peter, Use below code. leaflet(df) %>% addTiles() %>% ...READ MORE

answered Sep 17 in Data Analytics by priya
30 views
0 votes
1 answer

How to add external markers in maps?

Use external markers by creating icons using ...READ MORE

answered Oct 14 in Data Analytics by Cherukuri
• 32,260 points
23 views
0 votes
0 answers

fix the map area using leaflet and use ggplot

I created a map using leaflet and ...READ MORE

Sep 18 in Data Analytics by anonymous
• 32,260 points
19 views
0 votes
1 answer

How to save leaflet object as an image?

Yes, you can save leaflet objects as ...READ MORE

answered Oct 28 in Data Analytics by Cherukuri
• 32,260 points
70 views
0 votes
1 answer

Add buttons to perform actions on the leaflet map.

@ch, You can add easy buttons to add ...READ MORE

answered Oct 14 in Data Analytics by Cherukuri
• 32,260 points
34 views
0 votes
1 answer

How to change the datatype of any field in an external dataset in R?

Hi Anand, Try as below - class(dataset/dataframe$col_name) <- ...READ MORE

answered Jun 27 in Data Analytics by anonymous
• 32,260 points
38 views