Derive one default label per draggable region
Usage
make_region_labels(
x,
region_col,
label_col = region_col,
point = c("point_on_surface", "centroid")
)See also
as_drag_labels() for user-supplied labels; as_drag_annotations()
for draggable info boxes; apply_label_state() to restore saved positions;
drag_map_prototype() which accepts the result as its labels argument.
Examples
poly <- sf::st_sf(
region = c("North", "South"),
geometry = sf::st_sfc(
sf::st_polygon(list(rbind(c(0,1e5),c(1e5,1e5),c(1e5,2e5),c(0,2e5),c(0,1e5)))),
sf::st_polygon(list(rbind(c(0,0),c(1e5,0),c(1e5,1e5),c(0,1e5),c(0,0)))),
crs = 3857
)
)
make_region_labels(poly, region_col = "region")
#> label_id region label x y label_type width_px height_px connector
#> 1 North North North 50000 150000 label NA NA FALSE
#> 2 South South South 50000 50000 label NA NA FALSE
#> connector_type connector_mid_x connector_mid_y connector_start_x
#> 1 straight NA NA NA
#> 2 straight NA NA NA
#> connector_start_y
#> 1 NA
#> 2 NA
