Build a leaflet map from a shapefile in a context of multiple map sets and corresponding shapefiles.

build_mapset(shp, all_regions, ids, mapset, mapsets, default = "",
  default.name = default, all_locs_shapefile, xyz, color = c("#000000",
  "#000000", "#3C8DBC"), fill = c("#000000", "#3C8DBC", "#3C8DBC"),
  color_opacity = c(0.5, 1, 1), fill_opacity = c(0, 0, 0.4), progress = F)

Arguments

shp

a shapefile pertaining to a single mapset.

all_regions

a named vector of region IDs pertaining to regions in shp.

ids

literal names of regions in shp (may not match regions elements).

mapset

character, name of a mapset in mapsets.

mapsets

character, vector of all available map sets.

default

name of a default map set, if used. Otherwise defaults to default="".

default.name

label used in place of default string. Defaults to default.

all_locs_shapefile

a named list (names match mapsets) where each list element is a vector of regions specified to match the region IDs in shp.

xyz

a named list (names match mapsets) where each list element is a vector of three values: longitude, latitude, and zoom level, for centering and zoom level setup. Alternatively, a non-list vector of three values if all map sets will share a common centering and zoom level.

color

vector of three polygon border colors. See details.

fill

vector of three polygon fill colors. See details.

color_opacity

numeric vector of three polygon border color opacities. See details.

fill_opacity

numeric vector of three polygon fill color opacities. See details.

progress

logical, add progress bar in app during map rendering. Helpful is rendering is slow.

Value

a leaflet map

Details

This function builds a leaflet map from a shapefile. There can be a list of shapefiles, and corresponding lists of map set names and parameters for setting up each map such as centering and zooming defaults.

Each mapset and shp may contain named subregions/polygons. Polygons have fill color, outline, and change appearance on mouse hover and click (selection).

A default map may be identified, and if so, it is assumed to be a simpler base map with only a single polygon. Such a map set has one region, and therefore is fully colored as permanently "selected", with no need to click a polygon.

Polygon border and fill colors and opacities are vectors of three values each. These correspond to unselected, highlighted and selected polygons, respectively. While build_mapset deals primarily with unselected or highlighted polygons and update_mapset deals strictly with selected polygons, build_mapset still takes a third value because this is used in the case of a default map set consisting of a single polygon (which is always colored and filled as a "selected" polygon).

Examples

#not run