Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
37,476 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
title: "Most basic background map with R and Leaflet" | ||
descriptionMeta: "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." | ||
descriptionTop: "The R `leaflet` package allows to build interactive [maps](map.html) with R. This post explains how to zoom on a specific part of the map, with explanation and reproducible code." | ||
sectionText: "Background map section" | ||
sectionLink: "map.html" | ||
DataToVizText: "About Maps" | ||
DataToVizLink: "data-to-viz.com/graph/map.html" | ||
url: "179-2-select-a-zone-in-leaflet-map" | ||
output: | ||
html_document: | ||
self_contained: false | ||
mathjax: default | ||
lib_dir: libs | ||
template: template_rgg.html | ||
css: style.css | ||
toc: TRUE | ||
toc_float: TRUE | ||
toc_depth: 2 | ||
df_print: "paged" | ||
--- | ||
|
||
|
||
```{r global options, include = FALSE} | ||
knitr::opts_chunk$set( warning=FALSE, message=FALSE) | ||
``` | ||
|
||
<div class="container" style="padding-top: 80px"> | ||
|
||
|
||
|
||
|
||
<div class = "row"> | ||
|
||
<div class = "col-md-6 col-sm-12 align-self-center"> | ||
|
||
The previous [most basic map](179-show-a-map-with-leaflet-r.html) 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: | ||
|
||
- Longitude (`lng`) goes between -180 (West) and +180 (East). | ||
- Latitude (`lat`) goes between -90 (South) and +90 (North). | ||
- Zoom is controled using the `zoom` argument. | ||
|
||
</div> | ||
|
||
|
||
<div class = "col-md-6 col-sm-12"> | ||
|
||
<center><iframe src="HtmlWidget/backgroundMapZoom.html" height="400" width="100%" style="border:none; max-width: 500px"></iframe></center> | ||
|
||
</div> | ||
</div> | ||
|
||
<br><br> | ||
|
||
```{r, eval=FALSE} | ||
# 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")) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
|
||
|
||
|
||
|
||
```{r, echo=FALSE} | ||
htmltools::includeHTML("htmlChunkRelatedMap.html") | ||
``` |
Oops, something went wrong.