Adding tiles to map
Since above code creates a map widget that is empty. To add tiles to it for the creation of the desired map we use the addTiles() function of the leaflet package. By default, if no argument is passed it creates an OpenStreetMap map tile on top of the map widget. For custom map tile we pass that map as an argument to the addTiles() function.
Syntax: map <- leaflet() %>%addTiles()
Basic map with OpenStreetMap tile
# load leaflet library
library(leaflet)
# create map widget with OpenStreetMap tile
map <- leaflet() %>%
addTiles()
# print map widget
map
Output:
Leaflet package in R
The leaflet is one of the most popular open-source JavaScript libraries for mobile-friendly interactive maps. It’s used widely by many top organizations in the world. To use leaflet in r functionality in the R Programming Language, we have the leaflet package library. The leaflet in r package is an easy-to-use library that is designed with simplicity, performance, and usability all around.
Table of Content
- Features of the leaflet in R
- Installation of leaflet in R
- Creating Interactive maps using leaflet leaflet in R
- Adding tiles to map
- Adding Markers on Map
- Layer Control
- Plot data on top of map