Recently I wanted to create a leaflet map with a specific type of map style but I could not find an appropriate design on the web. I found out that you can use Mapbox Studio to easily design your own maps and use them from within the r package for leaflet. With the code down below we will get an interactive map for Hamburg with our own little design.
# packages require(leaflet) # set tiles parameters tcu_map = "YourLeafletURL" map_attr = "© <a href='https://www.mapbox.com/map-feedback/'>Mapbox</a> Basemap © <a href='https://insidedatablog.wordpress.com/'>Inside Data Design</a>" # plot leaflet() %>% setView(lng = 9.993682, lat = 53.551085, zoom = 11) %>% addTiles(urlTemplate = tcu_map, attribution = map_attr)
First we have to visit the Mapbox website, sign up for an account and create our own map via Mapbox Studio. After creating your own style (the best is to start from a default style and manipulate it for your needs) they will offer you a URL which can be used to display your style in Leaflet. You will find the URL under styles and the dropdown menu of your own created style (next to the edit button). If you haven`t created any style yet go to “New style” to create your first own map design.
Make sure you check out the code on my Github along with other projects.