Skip to contents

First load the data and some libraries:

Then a plot can be created in leaflet

bounds <- as.vector(bbox(extent(leroy)))
base_map <- leaflet() %>% fitBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>% addTiles()
map2 <- base_map %>% addPolylines(data =  as(leroy,'SpatialLines'), color ="grey") %>% 
  addCircles(data =leroy,fillOpacity=0.3, opacity = 0.5, color="blue")
map3 <- map2 %>% addLegend(position= "topright", colors=c("grey","blue"), labels=c("lines","points") ,opacity = 0.7, title = "Leroy")
map4 <- map3 %>% addScaleBar(position="bottomleft",options=scaleBarOptions(maxWidth = 100, metric = TRUE, imperial = F, updateWhenIdle = TRUE))
map4