The R leaflet
package allows to build interactive
maps with R. This post explains how to zoom
on a specific part of the map, with explanation and reproducible
code.
The previous
most basic map with
leaflet
explains how to show a map with the R
leaflet
package.
To specify which area of the map you want to display, just specify
latitude, longitude and how much you want to zoom in the
setView()
call:
lng
) goes between -180 (West) and +180
(East).
lat
) goes between -90 (South) and +90
(North).
zoom
argument.# Load the library
library(leaflet)
# Note: if you do not already installed it, install it with:
# install.packages("leaflet")
# Make the map
m <- leaflet() %>%
addTiles() %>%
setView( lng = 166.45, lat = -22.25, zoom = 8 )
m
# save the widget in a html file if needed.
# library(htmlwidgets)
# saveWidget(m, file=paste0( getwd(), "/HtmlWidget/backgroundMapZoom.html"))