Skip to content

Commit

Permalink
Leaflet section background ok
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed May 7, 2019
1 parent ce6613d commit c4b07bd
Show file tree
Hide file tree
Showing 71 changed files with 37,476 additions and 628 deletions.
87 changes: 87 additions & 0 deletions 179-2-select-a-zone-in-leaflet-map.Rmd
@@ -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")
```

0 comments on commit c4b07bd

Please sign in to comment.