Using leaflet to create interactive maps

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.5.1
my_map <-leaflet()%>%
  addTiles()
my_map

Adding Markers

library(leaflet)
my_map <-my_map%>%
  addMarkers(lat=39.2980803,lng=-76.5898801,popup="Jeff Leek's Office")
my_map

Adding many Markers

library(leaflet)
set.seed(2016-04-25)
df <-data.frame(lat=runif(20,min=39.2,max=39.3),lng=runif(20,min=-76.6,max=-76.5))
df%>%
  leaflet()%>%
  addTiles()%>%
  addMarkers()

Mapping Clusters

Mapping Circle Markers

Drawing Circles (Digitally)

## Assuming "lng" and "lat" are longitude and latitude, respectively

Drawing Rectangles

You can add rectangles on leaflet maps as well.

Adding Legends

Adding a legend can be useful if you have markers on your map with different colors.

## Assuming "lng" and "lat" are longitude and latitude, respectively