Design your own Leaflet maps with Mapbox Studio

bild12

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.

Advertisements

Author: inside data blog

data analysis & visualization blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s