Skip to content

Commit

Permalink
update with new bounds arg
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Jul 26, 2024
1 parent 41c1a07 commit 143b264
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 33 deletions.
28 changes: 14 additions & 14 deletions docs/articles/layers-overview.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/articles/map-design.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ articles:
layers-overview: layers-overview.html
map-design: map-design.html
shiny: shiny.html
last_built: 2024-07-26T21:21Z
last_built: 2024-07-26T21:25Z
urls:
reference: https://walker-data.com/mapgl/reference
article: https://walker-data.com/mapgl/articles
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions vignettes/layers-overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Geospatial practitioners in R will typically work with objects from the **sf** p

Objects of class `sf` can be specified as sources for the map either through the `add_source()` function or via the `source` parameter in one of **mapgl**'s layer functions. The `add_fill_layer()` function calls the Mapbox GL JS `addLayer()` function internally with a `fill` type, and enumerates the available options for styling the layer as function arguments.

**mapgl** users will often want to use the `fit_bounds(animate = FALSE)` function to fix the map view to a given layer's bounding box.
**mapgl** users will often want to use the `bounds` argument when initializing the map, or alternatively the `fit_bounds()` function, to fix the map view to a given layer's bounding box.

```{r, message = FALSE}
Expand All @@ -21,8 +21,7 @@ library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
mapboxgl() |>
fit_bounds(nc, animate = FALSE) |>
mapboxgl(bounds = nc) |>
add_fill_layer(id = "nc_data",
source = nc,
fill_color = "blue",
Expand All @@ -40,8 +39,8 @@ options(tigris_use_cache = TRUE)
loving_roads <- roads("TX", "Loving")
maplibre(style = maptiler_style("backdrop")) |>
fit_bounds(loving_roads, animate = FALSE) |>
maplibre(style = maptiler_style("backdrop"),
bounds = loving_roads) |>
add_line_layer(
id = "roads",
source = loving_roads,
Expand Down Expand Up @@ -88,8 +87,8 @@ random_points <- random_points %>%
mutate(category = sample(categories, n(), replace = TRUE))
# Map with circle layer
mapboxgl(style = mapbox_style("dark")) %>%
fit_bounds(random_points, animate = FALSE) %>%
mapboxgl(style = mapbox_style("dark"),
bounds = random_points) %>%
add_circle_layer(
id = "poi-layer",
source = random_points,
Expand Down Expand Up @@ -121,8 +120,8 @@ mapboxgl(style = mapbox_style("dark")) %>%
Symbol layers offer a wide range of arguments for customizing icon and label appearance; however not all arguments will work with all icons. The `icon_image` argument will look for a string that represents an icon found in the map style's sprite. [Read more about sprites here](https://docs.mapbox.com/style-spec/reference/sprite/).

```{r}
mapboxgl(style = mapbox_style("light")) |>
fit_bounds(random_points, animate = FALSE) |>
mapboxgl(style = mapbox_style("light"),
bounds = random_points) |>
add_symbol_layer(
id = "points-of-interest",
source = random_points,
Expand Down
4 changes: 2 additions & 2 deletions vignettes/map-design.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fl_age <- get_acs(
geometry = TRUE
)
fl_map <- mapboxgl(mapbox_style("light")) |>
fit_bounds(fl_age, animate = FALSE)
fl_map <- mapboxgl(mapbox_style("light"),
bounds = fl_age)
fl_map
```
Expand Down

0 comments on commit 143b264

Please sign in to comment.