Skip to content

Commit

Permalink
Add notebook for leaflet.extras2 issue *
Browse files Browse the repository at this point in the history
  • Loading branch information
florisvdh committed Feb 27, 2023
1 parent 159554b commit 910f96c
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.Rproj.user/
.Rhistory
*.html
*.zip
93 changes: 93 additions & 0 deletions leaflet_issue_notebook.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
title: "Leaflet reprex for issue in leaflet.extras2"
author: "Floris Vanderhaeghe"
date: "2023-02-27"
output: html_notebook
editor_options:
chunk_output_type: inline
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(magrittr)
library(leaflet)
library(leaflet.extras2)
attrib_digvl <- "&copy; <a href=https://www.vlaanderen.be/digitaal-vlaanderen/onze-oplossingen/geografische-webdiensten/ons-gis-aanbod>Digitaal Vlaanderen</a>"
```

```{r}
add_wms_forestnature <- function(map,
layers = "am:am_patdat",
transparent = TRUE,
options = WMSTileOptions(
format = "image/png",
transparent = transparent
),
...) {
addWMSTiles(
map = map,
baseUrl = "https://www.mercator.vlaanderen.be/raadpleegdienstenmercatorpubliek/wms",
layers = layers,
options = options,
attribution = attrib_digvl,
...
)
}
```

```{r}
add_wms_forestnature_2 <- function(map,
layers = "am:am_patdat",
transparent = TRUE,
options = WMSTileOptions(
format = "image/png",
transparent = transparent
),
...) {
addWMS(
map = map,
baseUrl = "https://www.mercator.vlaanderen.be/raadpleegdienstenmercatorpubliek/wms",
layers = layers,
options = options,
attribution = attrib_digvl,
...
)
}
```


## Map with `leaflet::addWMSTiles()`

```{r}
leaflet() %>%
setView(lng = 4.68, lat = 50.82, zoom = 12) %>%
addTiles() %>%
add_wms_forestnature(group = "Forest_Nature") %>%
addLayersControl(
overlayGroups = "Forest_Nature",
options = layersControlOptions(collapsed = FALSE)
)
```


## Map with `leaflet.extras2::addWMS()`

```{r}
leaflet() %>%
setView(lng = 4.68, lat = 50.82, zoom = 12) %>%
addTiles() %>%
add_wms_forestnature_2(group = "Forest_Nature") %>%
addLayersControl(
overlayGroups = "Forest_Nature",
options = layersControlOptions(collapsed = FALSE)
)
```

```{r}
sessioninfo::session_info()
```


0 comments on commit 910f96c

Please sign in to comment.