Add buttons to perform actions on the leaflet map

0 votes
Can anyone help me explain how to add buttons to perform actions on the leaflet map?
Oct 14, 2019 in Data Analytics by ch
• 3,450 points
4,831 views

1 answer to this question.

0 votes

@ch,

You can add easy buttons to add small JS events using addEasyButton() function.

Check out the below example -

leaflet() %>% addTiles() %>%
  addEasyButton(easyButton(
    icon="fa-globe", title="Zoom to Level 1",
    onClick=JS("function(btn, map){ map.setZoom(1); }"))) %>%
  addEasyButton(easyButton(
    icon="fa-crosshairs", title="Locate Me",
    onClick=JS("function(btn, map){ map.locate({setView: true}); }")))

Find more information about the example from the below link,

https://rstudio.github.io/leaflet/morefeatures.html

answered Oct 14, 2019 by Cherukuri
• 33,030 points

Related Questions In Data Analytics

0 votes
1 answer

How to add regression line equation and R2 on graph?

Below is one solution: # GET EQUATION AND ...READ MORE

answered Jun 1, 2018 in Data Analytics by DataKing99
• 8,250 points
6,731 views
0 votes
1 answer

R language has several packages for solving a problem. How do you make a decision on which one is the best to use?

CRAN package ecosystem has more than 6000 ...READ MORE

answered Jun 5, 2018 in Data Analytics by zombie
• 3,790 points
1,152 views
0 votes
1 answer

How do I add Icons to my messages on my dashboard which I’m creating using shiny r?

Try something like this: dashboardHeader(title="Edureka", dropdownMenu type = "message", messageItem(from = ...READ MORE

answered Nov 30, 2018 in Data Analytics by Maverick
• 10,840 points
874 views
0 votes
1 answer

Add radio buttons on shiny R dashboard

Yess of course that's possible. ShinyR provides ...READ MORE

answered Dec 5, 2018 in Data Analytics by Maverick
• 10,840 points
3,543 views
0 votes
1 answer

plot map points from a dataframe

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

answered Sep 17, 2019 in Data Analytics by priya
921 views
0 votes
1 answer

How to add external markers in maps?

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

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
906 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, 2019 in Data Analytics by anonymous
• 33,030 points
664 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, 2019 in Data Analytics by Cherukuri
• 33,030 points
5,504 views
0 votes
1 answer

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

See below example, > p = colorFactor(palette = ...READ MORE

answered Oct 28, 2019 in Data Analytics by anonymous
• 33,030 points
8,909 views
0 votes
1 answer

How to add labels on bars in bar chart in ggplot?

Use geom_text() to add labels on the ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
3,961 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP