My first map
my_map<-leaflet() %>% addTiles()
my_map
my_map<-leaflet() %>% addTiles() %>% addMarkers(lat=39.2980803,lng=-76.5898801,popup = "Jeff Leek's Office")
my_map
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()
Custom markers
hopkinsIcon <- makeIcon(
iconUrl = "http://brand.jhu.edu/content/uploads/2014/06/university.shield.small_.blue_.png",
iconWidth = 31*215/230, iconHeight = 31,
iconAnchorX = 31*215/230/2, iconAnchorY = 16
)
hopkinsLatLong <- data.frame(
lat = c(39.2973166, 39.3288851, 39.2906617),
lng = c(-76.5929798, -76.6206598, -76.5469683))
hopkinsLatLong %>%
leaflet() %>%
addTiles() %>%
addMarkers(icon = hopkinsIcon)
hopkinsIcon <- makeIcon(
iconUrl = "http://brand.jhu.edu/content/uploads/2014/06/university.shield.small_.blue_.png",
iconWidth = 31*215/230, iconHeight = 31,
iconAnchorX = 31*215/230/2, iconAnchorY = 16
)
hopkinsLatLong <- data.frame(
lat = c(39.2973166, 39.3288851, 39.2906617, 39.2970681, 39.2824806),
lng = c(-76.5929798, -76.6206598, -76.5469683, -76.6150537, -76.6016766))
hopkinsLatLong %>%
leaflet() %>%
addTiles() %>%
addMarkers()
Mapping clusters
df<-data.frame(lat=runif(500,min=39.25,max=39.35),lng=runif(500,min=-76.65,max=-76.55))
df %>%
leaflet() %>%
addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions())
Circle markers
df<-data.frame(lat=runif(20,min=39.25,max=39.35),lng=runif(20,min=-76.65,max=-76.55))
df %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers()