This commit is contained in:
evmo 2026-03-06 15:46:39 +11:00
commit 116abafc09
58 changed files with 5749 additions and 0 deletions

107
man/addProtomaps.Rd Normal file
View file

@ -0,0 +1,107 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addProtomaps.R
\name{addProtomaps}
\alias{addProtomaps}
\title{Add a Protomaps layer to a Leaflet map}
\usage{
addProtomaps(
map,
url,
style = NULL,
flavor = c("light", "dark", "white", "grayscale", "black"),
colors = NULL,
paintRules = NULL,
labelRules = NULL,
backgroundColor = NULL,
lang = NULL,
attribution = "Protomaps",
options = protomapsOptions(),
layerId = NULL,
group = NULL
)
}
\arguments{
\item{map}{A leaflet map object created with \code{\link[leaflet]{leaflet}}.}
\item{url}{Character. URL to a PMTiles file or a tile endpoint with
\code{{z}/{x}/{y}.mvt} placeholders.}
\item{style}{Optional style object created with \code{\link{pmMinimal}} or
\code{\link{pmStyle}}. Provides a convenient way to apply preset styles.
If provided, overrides \code{colors} and \code{labelRules}.}
\item{flavor}{Character. Built-in flavor/theme to use. One of "light", "dark",
"white", "grayscale", or "black". Default is "light". Ignored if \code{style}
is provided.}
\item{colors}{Optional list of color overrides. Use \code{\link{pmColors}} to
create this. Overrides specific colors while keeping built-in rendering rules.}
\item{paintRules}{Optional list of paint rules created with \code{\link{pmPaintRule}}.
If provided, completely overrides the flavor's default paint rules.
For simple color changes, use \code{colors} instead.}
\item{labelRules}{Optional list of label rules created with \code{\link{pmLabelRule}}.
If provided, completely overrides the flavor's default label rules.}
\item{backgroundColor}{Character. Background color for the canvas.
Default is NULL (uses flavor default).}
\item{lang}{Character. Language code for labels (e.g., "en", "de", "zh").
Default is NULL (uses default language).}
\item{attribution}{Character. Attribution text for the layer.
Default is "Protomaps".}
\item{options}{A list of additional options created with \code{\link{protomapsOptions}}.}
\item{layerId}{Character. Layer ID for the protomaps layer.}
\item{group}{Character. Group name for layer control.}
}
\value{
A modified leaflet map object.
}
\description{
Adds a vector tile layer from a PMTiles source to a Leaflet map using
the protomaps-leaflet library. Supports built-in flavors and custom
styling rules.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Basic usage with demo tiles
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_demo_url())
# Using dark flavor
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_demo_url(), flavor = "dark")
# Custom colors with proper rendering
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(
url = protomaps_demo_url(),
colors = pmColors(earth = "#d3d3d3", water = "#1a3a5c")
)
# Using preset styles (recommended for common use cases)
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 10) \%>\%
addProtomaps(url = protomaps_demo_url(), style = pmStyle("minimal"))
# Custom minimal style
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 10) \%>\%
addProtomaps(
url = protomaps_demo_url(),
style = pmMinimal(land = "#f5f5f0", water = "#1a3a5c", labels = TRUE)
)
}
}

View file

@ -0,0 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmCenteredTextSymbolizer}
\alias{pmCenteredTextSymbolizer}
\title{Create a Centered Text Symbolizer}
\usage{
pmCenteredTextSymbolizer(
font = "12px sans-serif",
fill = "#000000",
stroke = NULL,
width = 0,
lineHeight = NULL,
labelProps = NULL,
...
)
}
\arguments{
\item{font}{Character. Font specification (e.g., "12px sans-serif").}
\item{fill}{Character. Text fill color. Default is "#000000".}
\item{stroke}{Character. Text stroke (halo) color. Default is NULL.}
\item{width}{Numeric. Stroke width for text halo. Default is 0.}
\item{lineHeight}{Numeric. Line height multiplier for multi-line labels.
Default is NULL (uses library default). Use values like 1.0-1.2 for
tighter spacing.}
\item{labelProps}{List. Properties to use for label text, in order of
preference. Default is \code{list("name")}.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a centered text symbolizer for rendering text labels centered
on point features.
}
\examples{
pmCenteredTextSymbolizer(font = "14px Arial", fill = "black")
# Tighter line spacing for multi-word labels
pmCenteredTextSymbolizer(font = "11px sans-serif", fill = "#444",
lineHeight = 1.1)
}

42
man/pmCircleSymbolizer.Rd Normal file
View file

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmCircleSymbolizer}
\alias{pmCircleSymbolizer}
\title{Create a Circle Symbolizer}
\usage{
pmCircleSymbolizer(
radius = 4,
fill = "#000000",
stroke = NULL,
width = 1,
opacity = 1,
...
)
}
\arguments{
\item{radius}{Numeric. Circle radius in pixels. Default is 4.}
\item{fill}{Character. Fill color for the circle. Default is "#000000".}
\item{stroke}{Character. Stroke (outline) color. Default is NULL.}
\item{width}{Numeric. Stroke width in pixels. Default is 1.}
\item{opacity}{Numeric. Fill opacity from 0 to 1. Default is 1.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a circle symbolizer for rendering point features as circles.
}
\examples{
# Simple red circle
pmCircleSymbolizer(radius = 6, fill = "red")
# Circle with stroke
pmCircleSymbolizer(radius = 8, fill = "white", stroke = "black", width = 2)
}

49
man/pmCityLabels.Rd Normal file
View file

@ -0,0 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{pmCityLabels}
\alias{pmCityLabels}
\title{Create preset label rules for city names}
\usage{
pmCityLabels(
style = c("hierarchical", "major-only", "all"),
color = "#333333",
halo = "white",
include_regions = TRUE
)
}
\arguments{
\item{style}{Character. Label style preset:
\describe{
\item{"hierarchical"}{Size varies by city importance (min_zoom)}
\item{"major-only"}{Only major cities (min_zoom <= 5)}
\item{"all"}{All cities with uniform styling}
}}
\item{color}{Character. Text color. Default is "#333333".}
\item{halo}{Character. Halo/stroke color. Default is "white".}
\item{include_regions}{Logical. Include state/region labels. Default is TRUE.}
}
\value{
A list of label rules to pass to \code{\link{addProtomaps}}.
}
\description{
Creates label rules for displaying city/place names with common styling
patterns.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 8) \%>\%
addProtomaps(
url = protomaps_url(),
colors = pmColors(earth = "#f0f0f0", water = "#1a3a5c"),
labelRules = pmCityLabels("hierarchical")
)
}
}

96
man/pmColors.Rd Normal file
View file

@ -0,0 +1,96 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colors.R
\name{pmColors}
\alias{pmColors}
\title{Create custom color overrides}
\usage{
pmColors(
background = NULL,
earth = NULL,
water = NULL,
park = NULL,
wood = NULL,
hospital = NULL,
industrial = NULL,
school = NULL,
beach = NULL,
glacier = NULL,
highway = NULL,
major = NULL,
minor = NULL,
city_label = NULL,
state_label = NULL,
country_label = NULL,
ocean_label = NULL,
...
)
}
\arguments{
\item{background}{Background color}
\item{earth}{Land/earth color}
\item{water}{Water color}
\item{park}{Park/green space color (also called park_a or park_b)}
\item{wood}{Forest/woodland color (also called wood_a or wood_b)}
\item{hospital}{Hospital area color}
\item{industrial}{Industrial area color}
\item{school}{School/university area color}
\item{beach}{Beach color}
\item{glacier}{Glacier color}
\item{highway}{Highway road color}
\item{major}{Major road color}
\item{minor}{Minor road color}
\item{city_label}{City label color}
\item{state_label}{State/region label color}
\item{country_label}{Country label color}
\item{ocean_label}{Ocean label color}
\item{...}{Additional color properties}
}
\value{
A list of color overrides to pass to \code{\link{addProtomaps}}.
}
\description{
Creates a list of color overrides that can be applied to a built-in flavor.
This is the recommended way to customize map colors while keeping the
proper rendering rules (zoom handling, polygon simplification, etc.).
}
\examples{
# Simple earth and water colors
pmColors(earth = "#d3d3d3", water = "#1a3a5c")
# Dark theme with custom colors
pmColors(
background = "#1a1a2e",
earth = "#1a1a2e",
water = "#16213e",
park = "#1f4037",
highway = "#4a4a6a"
)
# Minimal grayscale
pmColors(
background = "#ffffff",
earth = "#f5f5f5",
water = "#e0e0e0"
)
}
\seealso{
\code{\link{addProtomaps}}, \code{\link{protomaps_colors}}
}

39
man/pmHideFeatures.Rd Normal file
View file

@ -0,0 +1,39 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{pmHideFeatures}
\alias{pmHideFeatures}
\title{Create color overrides to hide specific features}
\usage{
pmHideFeatures(features, background = "#f8f8f8")
}
\arguments{
\item{features}{Character vector. Features to hide. Options include:
"roads", "buildings", "landuse", "boundaries", "labels".}
\item{background}{Character. Background color that hidden features will
match. Default is "#f8f8f8".}
}
\value{
A list of color overrides to pass to \code{\link{pmColors}} or
merge with other colors.
}
\description{
Creates color settings that hide specified feature categories by making
them match the background color.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Hide roads and buildings but keep parks visible
hidden <- pmHideFeatures(c("roads", "buildings"))
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(
url = protomaps_url(),
colors = modifyList(pmColors(water = "#1a3a5c"), hidden)
)
}
}

54
man/pmLabelRule.Rd Normal file
View file

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rules.R
\name{pmLabelRule}
\alias{pmLabelRule}
\title{Create a Label Rule}
\usage{
pmLabelRule(
dataLayer,
symbolizer,
minzoom = NULL,
maxzoom = NULL,
filter = NULL
)
}
\arguments{
\item{dataLayer}{Character. The name of the data layer in the vector
tile source (e.g., "places", "roads").}
\item{symbolizer}{A text symbolizer object created with one of
\code{\link{pmTextSymbolizer}}, \code{\link{pmCenteredTextSymbolizer}},
\code{\link{pmLineLabelSymbolizer}}, or \code{\link{pmShieldSymbolizer}}.}
\item{minzoom}{Numeric. Minimum zoom level at which this rule applies.
Default is NULL (applies at all zoom levels).}
\item{maxzoom}{Numeric. Maximum zoom level at which this rule applies.
Default is NULL (applies at all zoom levels).}
\item{filter}{Character. A JavaScript expression string that filters
features. Default is NULL (no filter).}
}
\value{
A list representing the label rule configuration.
}
\description{
Creates a label rule that specifies how to render text labels for
features from a particular data layer. Label rules control text
placement and styling, with automatic collision detection.
}
\examples{
# Label cities
pmLabelRule("places",
pmCenteredTextSymbolizer(font = "14px Arial",
fill = "black",
stroke = "white",
width = 2))
# Label streets along their paths
pmLabelRule("roads",
pmLineLabelSymbolizer(font = "11px Arial",
fill = "#333"),
minzoom = 14)
}

View file

@ -0,0 +1,40 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmLineLabelSymbolizer}
\alias{pmLineLabelSymbolizer}
\title{Create a Line Label Symbolizer}
\usage{
pmLineLabelSymbolizer(
font = "12px sans-serif",
fill = "#000000",
stroke = NULL,
width = 0,
labelProps = NULL,
...
)
}
\arguments{
\item{font}{Character. Font specification (e.g., "12px sans-serif").}
\item{fill}{Character. Text fill color. Default is "#000000".}
\item{stroke}{Character. Text stroke (halo) color. Default is NULL.}
\item{width}{Numeric. Stroke width for text halo. Default is 0.}
\item{labelProps}{List. Properties to use for label text.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a line label symbolizer for rendering text labels along line
features (e.g., street names).
}
\examples{
pmLineLabelSymbolizer(font = "11px Arial", fill = "#333",
stroke = "white", width = 2)
}

54
man/pmLineSymbolizer.Rd Normal file
View file

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmLineSymbolizer}
\alias{pmLineSymbolizer}
\title{Create a Line Symbolizer}
\usage{
pmLineSymbolizer(
color = "#000000",
width = 1,
dash = NULL,
dashColor = NULL,
dashWidth = NULL,
lineCap = NULL,
lineJoin = NULL,
opacity = 1,
...
)
}
\arguments{
\item{color}{Character. Line color. Default is "#000000".}
\item{width}{Numeric or function. Line width in pixels. Can be a fixed
value or a zoom-dependent specification.}
\item{dash}{List or NULL. Dash pattern as a vector of numbers, e.g.,
\code{c(4, 2)} for 4px dash, 2px gap.}
\item{dashColor}{Character. Color for dashes if using dash pattern.}
\item{dashWidth}{Numeric. Width of dashes.}
\item{lineCap}{Character. Line cap style: "butt", "round", or "square".}
\item{lineJoin}{Character
. Line join style: "miter", "round", or "bevel".}
\item{opacity}{Numeric. Line opacity from 0 to 1. Default is 1.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a line symbolizer for rendering line features.
}
\examples{
# Simple black line
pmLineSymbolizer(color = "black", width = 2)
# Dashed line
pmLineSymbolizer(color = "gray", width = 1, dash = c(4, 2))
}

52
man/pmMinimal.Rd Normal file
View file

@ -0,0 +1,52 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{pmMinimal}
\alias{pmMinimal}
\title{Create a minimal basemap style}
\usage{
pmMinimal(
land = "#f8f8f8",
water = "#e0e8f0",
labels = FALSE,
label_color = "#666666"
)
}
\arguments{
\item{land}{Character. Color for all land features. Default is "#f8f8f8".}
\item{water}{Character. Color for water features. Default is "#e0e8f0".}
\item{labels}{Logical. Whether to show city labels. Default is FALSE.}
\item{label_color}{Character. Color for labels if shown. Default is "#666666".}
}
\value{
A list with \code{colors} and \code{labelRules} components to pass to
\code{\link{addProtomaps}}.
}
\description{
Creates a minimal style with uniform land color, hiding roads, buildings,
and most labels. Ideal for data visualization overlays.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Ultra-minimal basemap
style <- pmMinimal()
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 10) \%>\%
addProtomaps(url = protomaps_url(), style = style)
# Custom colors with major city labels
style <- pmMinimal(land = "#f5f5f0", water = "#1a3a5c", labels = TRUE)
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 8) \%>\%
addProtomaps(url = protomaps_url(), style = style)
}
}
\seealso{
\code{\link{pmStyle}}, \code{\link{addProtomaps}}
}

62
man/pmModifyStyle.Rd Normal file
View file

@ -0,0 +1,62 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{pmModifyStyle}
\alias{pmModifyStyle}
\title{Modify an Existing Style}
\usage{
pmModifyStyle(
style,
colors = NULL,
labelRules = NULL,
replace_labels = FALSE,
...
)
}
\arguments{
\item{style}{A pm_style object to modify.}
\item{colors}{Named list of color overrides (from pmColors() or manual list).}
\item{labelRules}{Optional list of label rules to replace or add.}
\item{replace_labels}{Logical. If TRUE, replaces all label rules. If FALSE,
appends new rules. Default is FALSE.}
\item{...}{Additional color overrides as named arguments.}
}
\value{
A new pm_style object with modifications applied.
}
\description{
Creates a new pm_style by modifying an existing one. Useful for tweaking
preset styles without rebuilding from scratch.
}
\examples{
\dontrun{
# Start with watercolor, change water color
my_style <- pmModifyStyle(pmStyle("watercolor"), water = "#1a3a5c")
# Add label rules to minimal style
my_style <- pmModifyStyle(
pmMinimal(),
labelRules = pmCityLabels("major-only")
)
# Multiple modifications
my_style <- pmModifyStyle(
pmStyle("muted"),
colors = pmColors(water = "#2a4a6c", park = "#c0d8c0"),
replace_labels = TRUE,
labelRules = list(
pmLabelRule("places", pmCenteredTextSymbolizer(
font = "bold 14px Arial",
fill = "#333"
))
)
)
}
}
\seealso{
\code{\link{pmStyle}}, \code{\link{pmMinimal}}
}

54
man/pmPaintRule.Rd Normal file
View file

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rules.R
\name{pmPaintRule}
\alias{pmPaintRule}
\title{Create a Paint Rule}
\usage{
pmPaintRule(
dataLayer,
symbolizer,
minzoom = NULL,
maxzoom = NULL,
filter = NULL
)
}
\arguments{
\item{dataLayer}{Character. The name of the data layer in the vector
tile source (e.g., "water", "earth", "roads").}
\item{symbolizer}{A symbolizer object created with one of the symbolizer
functions (e.g., \code{\link{pmPolygonSymbolizer}},
\code{\link{pmLineSymbolizer}}).}
\item{minzoom}{Numeric. Minimum zoom level at which this rule applies.
Default is NULL (applies at all zoom levels).}
\item{maxzoom}{Numeric. Maximum zoom level at which this rule applies.
Default is NULL (applies at all zoom levels).}
\item{filter}{Character. A JavaScript expression string that filters
features. The expression has access to \code{zoom} and \code{feature}
variables. Default is NULL (no filter).}
}
\value{
A list representing the paint rule configuration.
}
\description{
Creates a paint rule that specifies how to render features from a
particular data layer. Paint rules control the visual appearance of
polygon, line, and point features.
}
\examples{
# Render water polygons in blue
pmPaintRule("water", pmPolygonSymbolizer(fill = "steelblue"))
# Render roads with zoom-dependent visibility
pmPaintRule("roads", pmLineSymbolizer(color = "gray", width = 2),
minzoom = 10)
# Filter to only show highways
pmPaintRule("roads",
pmLineSymbolizer(color = "orange", width = 4),
filter = "feature.props.kind === 'highway'")
}

61
man/pmPalette.Rd Normal file
View file

@ -0,0 +1,61 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/palette.R
\name{pmPalette}
\alias{pmPalette}
\title{Apply Color Palette to Land Use Categories}
\usage{
pmPalette(palette, categories = NULL, n = NULL, background = "#f8f8f8")
}
\arguments{
\item{palette}{Character vector of colors, or a function that generates colors.
Can be output from viridis::viridis(), RColorBrewer::brewer.pal(), etc.}
\item{categories}{Character vector of category names to map colors to.
Default maps to common land use types: water, park, wood, residential,
commercial, industrial.}
\item{n}{Integer. Number of colors to generate if palette is a function.
Default is NULL (uses length of categories).}
\item{background}{Character. Background/default color for unassigned categories.
Default is "#f8f8f8".}
}
\value{
A list of color mappings suitable for pmColors() or addProtomaps(colors=).
}
\description{
Maps colors from a palette to land use categories, enabling use of
viridis, RColorBrewer, and other R color palettes with Protomaps.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Using viridis palette for land use
if (requireNamespace("viridisLite", quietly = TRUE)) {
colors <- pmPalette(viridisLite::viridis(6))
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_url(), colors = colors)
}
# Using RColorBrewer
if (requireNamespace("RColorBrewer", quietly = TRUE)) {
colors <- pmPalette(RColorBrewer::brewer.pal(6, "Set2"))
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_url(), colors = colors)
}
# Custom category mapping
colors <- pmPalette(
c("#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"),
categories = c("water", "park", "sand", "buildings", "highway")
)
}
}
\seealso{
\code{\link{pmPaletteStyle}}, \code{\link{pmColors}}
}

57
man/pmPaletteStyle.Rd Normal file
View file

@ -0,0 +1,57 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/palette.R
\name{pmPaletteStyle}
\alias{pmPaletteStyle}
\title{Create a Themed Palette Style}
\usage{
pmPaletteStyle(
palette,
water_color = NULL,
land_color = "#f8f8f8",
labels = TRUE,
label_color = "#333333"
)
}
\arguments{
\item{palette}{Character vector of colors or palette function.}
\item{water_color}{Character. Color for water features. If NULL, uses
first color from palette.}
\item{land_color}{Character. Color for land/background. Default is "#f8f8f8".}
\item{labels}{Logical. Whether to include city labels. Default is TRUE.}
\item{label_color}{Character. Color for labels. Default is "#333333".}
}
\value{
A pm_style object.
}
\description{
Creates a complete pm_style using a color palette. Combines pmPalette()
with styling for a consistent look.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Viridis-themed map
if (requireNamespace("viridisLite", quietly = TRUE)) {
style <- pmPaletteStyle(viridisLite::viridis(5, option = "D"))
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_url(), style = style)
}
# Custom palette
style <- pmPaletteStyle(
c("#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"),
water_color = "#264653"
)
}
}
\seealso{
\code{\link{pmPalette}}, \code{\link{pmStyle}}
}

View file

@ -0,0 +1,43 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmPolygonSymbolizer}
\alias{pmPolygonSymbolizer}
\title{Create a Polygon Symbolizer}
\usage{
pmPolygonSymbolizer(
fill = "#cccccc",
stroke = NULL,
width = 1,
opacity = 1,
pattern = NULL,
...
)
}
\arguments{
\item{fill}{Character. Fill color for the polygon. Can be a CSS color
string or a function specification.}
\item{stroke}{Character. Stroke (outline) color. Default is NULL (no stroke).}
\item{width}{Numeric. Stroke width in pixels. Default is 1.}
\item{opacity}{Numeric. Fill opacity from 0 to 1. Default is 1.}
\item{pattern}{Character. Fill pattern. One of NULL, "hatch", or "dot".}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a polygon symbolizer for rendering filled polygon features.
}
\examples{
# Simple blue fill
pmPolygonSymbolizer(fill = "steelblue")
# With stroke
pmPolygonSymbolizer(fill = "#f0f0f0", stroke = "#333", width = 2)
}

43
man/pmShieldSymbolizer.Rd Normal file
View file

@ -0,0 +1,43 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmShieldSymbolizer}
\alias{pmShieldSymbolizer}
\title{Create a Shield Symbolizer}
\usage{
pmShieldSymbolizer(
font = "10px sans-serif",
fill = "#000000",
background = "#ffffff",
stroke = "#000000",
padding = 2,
labelProps = NULL,
...
)
}
\arguments{
\item{font}{Character. Font specification for shield text.}
\item{fill}{Character. Text fill color. Default is "#000000".}
\item{background}{Character. Shield background color. Default is "#ffffff".}
\item{stroke}{Character. Shield border color. Default is "#000000".}
\item{padding}{Numeric. Padding inside the shield in pixels. Default is 2.}
\item{labelProps}{List. Properties to use for shield text.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a shield symbolizer for rendering labeled badges or shields
(e.g., highway route markers).
}
\examples{
pmShieldSymbolizer(font = "10px Arial", fill = "black",
background = "white", stroke = "black")
}

47
man/pmStyle.Rd Normal file
View file

@ -0,0 +1,47 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{pmStyle}
\alias{pmStyle}
\title{Get a preset map style}
\usage{
pmStyle(
name = c("minimal", "minimal-dark", "muted", "watercolor", "ink", "terrain", "transit")
)
}
\arguments{
\item{name}{Character. Name of the preset style. One of:
\describe{
\item{"minimal"}{Light gray land, light blue water, no labels}
\item{"minimal-dark"}{Dark land, dark blue water, no labels}
\item{"muted"}{Subtle colors, faint roads, major labels only}
\item{"watercolor"}{Soft, painterly aesthetic}
\item{"ink"}{Black lines on white, like a pen drawing}
\item{"terrain"}{Earthy tones with subtle elevation feel}
\item{"transit"}{Muted base with emphasized rail lines}
}}
}
\value{
A list with style components to pass to \code{\link{addProtomaps}}.
}
\description{
Returns a preset style configuration. Available presets provide common
styling patterns without manual configuration.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 10) \%>\%
addProtomaps(url = protomaps_url(), style = pmStyle("minimal"))
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 10) \%>\%
addProtomaps(url = protomaps_url(), style = pmStyle("watercolor"))
}
}
\seealso{
\code{\link{pmMinimal}}, \code{\link{addProtomaps}}
}

48
man/pmTextSymbolizer.Rd Normal file
View file

@ -0,0 +1,48 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/symbolizers.R
\name{pmTextSymbolizer}
\alias{pmTextSymbolizer}
\title{Create a Text Symbolizer}
\usage{
pmTextSymbolizer(
font = "12px sans-serif",
fill = "#000000",
stroke = NULL,
width = 0,
labelProps = NULL,
textTransform = NULL,
...
)
}
\arguments{
\item{font}{Character. Font specification (e.g., "12px sans-serif").}
\item{fill}{Character. Text fill color. Default is "#000000".}
\item{stroke}{Character. Text stroke (halo) color. Default is NULL.}
\item{width}{Numeric. Stroke width for text halo. Default is 0.}
\item{labelProps}{List. Properties to use for label text, in order of
preference. Default is \code{list("name")}.}
\item{textTransform}{Character. Text transformation: "uppercase",
"lowercase", or NULL.}
\item{...}{Additional symbolizer options.}
}
\value{
A list representing the symbolizer configuration.
}
\description{
Creates a text symbolizer for rendering text labels.
}
\examples{
# Simple text label
pmTextSymbolizer(font = "12px Arial", fill = "black")
# Text with halo
pmTextSymbolizer(font = "14px sans-serif", fill = "black",
stroke = "white", width = 2)
}

19
man/print.pm_style.Rd Normal file
View file

@ -0,0 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/styles.R
\name{print.pm_style}
\alias{print.pm_style}
\title{Print method for pm_style objects}
\usage{
\method{print}{pm_style}(x, ...)
}
\arguments{
\item{x}{A pm_style object.}
\item{...}{Additional arguments (ignored).}
}
\value{
Invisibly returns x.
}
\description{
Prints a formatted summary of a pm_style object showing colors and label rules.
}

73
man/protomapr-package.Rd Normal file
View file

@ -0,0 +1,73 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/protomapr-package.R
\docType{package}
\name{protomapr-package}
\alias{protomapr}
\alias{protomapr-package}
\title{protomapr: Add Protomaps Layers to Leaflet Maps}
\description{
The protomapr package provides functions to add Protomaps vector tile
layers to leaflet maps in R. Unlike raster tile providers, Protomaps
offers full customization of colors and features, self-hosting from a
single PMTiles file, and smooth vector rendering at any zoom level.
See \code{vignette("getting-started")} for why you might choose Protomaps
over standard provider tiles.
}
\section{Main Functions}{
\describe{
\item{\code{\link{addProtomaps}}}{Add a Protomaps layer to a Leaflet map}
\item{\code{\link{protomapsOptions}}}{Configure additional layer options}
}
}
\section{Symbolizers}{
\describe{
\item{\code{\link{pmPolygonSymbolizer}}}{Style polygon features}
\item{\code{\link{pmLineSymbolizer}}}{Style line features}
\item{\code{\link{pmCircleSymbolizer}}}{Style point features as circles}
\item{\code{\link{pmTextSymbolizer}}}{Add text labels}
\item{\code{\link{pmCenteredTextSymbolizer}}}{Add centered text labels}
\item{\code{\link{pmLineLabelSymbolizer}}}{Add labels along lines}
\item{\code{\link{pmShieldSymbolizer}}}{Add shield/badge labels}
}
}
\section{Rules}{
\describe{
\item{\code{\link{pmPaintRule}}}{Define how to paint features}
\item{\code{\link{pmLabelRule}}}{Define how to label features}
}
}
\section{Available Themes}{
The following built-in themes are available:
\itemize{
\item \code{"light"} - General-purpose light basemap
\item \code{"dark"} - General-purpose dark basemap
\item \code{"white"} - High-contrast white theme for data visualization
\item \code{"grayscale"} - Monochromatic theme
\item \code{"black"} - Dark theme for data visualization
}
}
\seealso{
Useful links:
\itemize{
\item \url{https://github.com/evmo/protomapr}
}
}
\author{
\strong{Maintainer}: Evan Morrison \email{evan@p34.au}
Other contributors:
\itemize{
\item Brandon Liu (Author of protomaps-leaflet JavaScript library) [copyright holder]
}
}
\keyword{internal}

View file

@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addProtomaps.R
\name{protomapsDependency}
\alias{protomapsDependency}
\title{Create Protomaps HTML dependency}
\usage{
protomapsDependency(version = "5.1.0")
}
\arguments{
\item{version}{Character. Version of protomaps-leaflet to use.
Default is "5.1.0".}
}
\value{
An htmltools::htmlDependency object.
}
\description{
Creates the HTML dependency for the protomaps-leaflet JavaScript library.
This is automatically included when using \code{\link{addProtomaps}}.
}
\examples{
protomapsDependency()
}

28
man/protomapsOptions.Rd Normal file
View file

@ -0,0 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addProtomaps.R
\name{protomapsOptions}
\alias{protomapsOptions}
\title{Protomaps layer options}
\usage{
protomapsOptions(maxDataZoom = NULL, tileSize = NULL, debug = FALSE, ...)
}
\arguments{
\item{maxDataZoom}{Numeric. Maximum zoom level to fetch tile data.
Tiles beyond this zoom will be overzoomed.}
\item{tileSize}{Numeric. Size of tiles in pixels. Default is 256.}
\item{debug}{Logical. Enable debug mode to visualize tile boundaries.}
\item{...}{Additional options passed to the layer.}
}
\value{
A list of options.
}
\description{
Create additional options for protomaps layer configuration.
}
\examples{
protomapsOptions(maxDataZoom = 14, tileSize = 512)
}

View file

@ -0,0 +1,28 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sample-tiles.R
\name{protomaps_clear_cache}
\alias{protomaps_clear_cache}
\title{Clear Cached Sample Tiles}
\usage{
protomaps_clear_cache(cache_dir = NULL)
}
\arguments{
\item{cache_dir}{Character. Cache directory. Default uses same as
\code{\link{protomaps_sample_tiles}}.}
}
\value{
Invisibly returns TRUE if files were removed, FALSE otherwise.
}
\description{
Removes cached sample PMTiles files to free disk space.
}
\examples{
\dontrun{
# Clear all cached tiles
protomaps_clear_cache()
}
}
\seealso{
\code{\link{protomaps_sample_tiles}}
}

72
man/protomaps_colors.Rd Normal file
View file

@ -0,0 +1,72 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/colors.R
\name{protomaps_colors}
\alias{protomaps_colors}
\title{Protomaps Color Properties Reference}
\description{
Reference documentation for all available color properties that can be
customized using \code{\link{pmColors}}.
}
\section{Base Colors}{
\describe{
\item{\code{background}}{Map background color}
\item{\code{earth}}{Land/terrain color}
\item{\code{water}}{Water bodies color}
}
}
\section{Land Use Colors}{
\describe{
\item{\code{park_a}, \code{park_b}}{Park colors (use \code{park} in pmColors)}
\item{\code{wood_a}, \code{wood_b}}{Forest/woodland colors (use \code{wood} in pmColors)}
\item{\code{hospital}}{Hospital areas}
\item{\code{industrial}}{Industrial zones}
\item{\code{school}}{Schools and universities}
\item{\code{beach}}{Beach areas}
\item{\code{zoo}}{Zoo areas}
\item{\code{aerodrome}}{Airport areas}
\item{\code{glacier}}{Glacier areas}
}
}
\section{Road Colors}{
\describe{
\item{\code{highway}}{Highway/motorway color}
\item{\code{major}}{Major road color}
\item{\code{minor_a}, \code{minor_b}}{Minor road colors (use \code{minor} in pmColors)}
\item{\code{railway}}{Railway lines}
\item{\code{pier}}{Pier/dock structures}
}
}
\section{Label Colors}{
\describe{
\item{\code{city_label}}{City name labels}
\item{\code{state_label}}{State/region labels}
\item{\code{country_label}}{Country name labels}
\item{\code{ocean_label}}{Ocean/sea labels}
\item{\code{roads_label_major}}{Major road name labels}
\item{\code{roads_label_minor}}{Minor road name labels}
}
}
\section{Landcover Colors (optional object)}{
These are specified as a nested object:
\describe{
\item{\code{grassland}}{Grassland areas}
\item{\code{barren}}{Barren land}
\item{\code{urban_area}}{Urban zones}
\item{\code{farmland}}{Agricultural areas}
\item{\code{forest}}{Forest areas}
\item{\code{scrub}}{Scrubland}
}
}
\seealso{
\code{\link{pmColors}}, \code{\link{addProtomaps}}
}

130
man/protomaps_layers.Rd Normal file
View file

@ -0,0 +1,130 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/layers.R
\name{protomaps_layers}
\alias{protomaps_layers}
\alias{layers}
\title{Protomaps Basemap Layers Reference}
\description{
Reference documentation for the available layers and properties in the
Protomaps basemap. Use these layer names with \code{\link{pmPaintRule}}
and \code{\link{pmLabelRule}}, and filter on these properties.
}
\section{Layer Names}{
The following layers are available for styling:
\describe{
\item{\code{earth}}{Land polygons}
\item{\code{water}}{Water polygons, lines, and label points}
\item{\code{landuse}}{Parks, forests, residential areas, etc.}
\item{\code{roads}}{Streets, highways, paths}
\item{\code{buildings}}{Building footprints and addresses}
\item{\code{places}}{City, town, and region labels}
\item{\code{pois}}{Points of interest}
\item{\code{boundaries}}{Administrative boundaries}
\item{\code{natural}}{Natural features like peaks, forests}
\item{\code{transit}}{Transit stations and lines}
}
}
\section{Places Layer Properties}{
Use these in filter expressions like \code{filter = "feature.props.kind === 'locality'"}
\describe{
\item{\code{kind}}{Place type: "country", "region", "locality", "macrohood", "neighbourhood"}
\item{\code{kind_detail}}{Detailed type: "city", "town", "village", "hamlet", "state", "province", "country"}
\item{\code{name}}{Place name}
\item{\code{population}}{Population count (integer)}
\item{\code{population_rank}}{Population rank (integer, higher = larger)}
\item{\code{min_zoom}}{Minimum zoom level where label appears (lower = more important)}
\item{\code{capital}}{Capital status (string)}
\item{\code{wikidata}}{Wikidata ID}
}
}
\section{Water Layer Properties}{
\describe{
\item{\code{kind}}{Water type: "water", "lake", "playa", "ocean", "other"}
\item{\code{kind_detail}}{Detailed type: "basin", "canal", "ditch", "dock", "drain", "lake", "reservoir", "river", "riverbank", "stream"}
\item{\code{name}}{Water body name}
\item{\code{intermittent}}{Boolean, seasonal water}
\item{\code{reservoir}}{Boolean}
\item{\code{alkaline}}{Boolean}
}
}
\section{Roads Layer Properties}{
\describe{
\item{\code{kind}}{Road class: "highway", "major_road", "medium_road", "minor_road", "path"}
\item{\code{kind_detail}}{Detailed type: "motorway", "trunk", "primary", "secondary", "tertiary", "residential", "service", "pedestrian", "footway", "cycleway"}
\item{\code{ref}}{Road reference number (e.g., "I-80", "US-101")}
\item{\code{name}}{Street name}
\item{\code{oneway}}{Boolean}
\item{\code{is_bridge}}{Boolean}
\item{\code{is_tunnel}}{Boolean}
}
}
\section{Landuse Layer Properties}{
\describe{
\item{\code{kind}}{Land use type: "park", "forest", "residential", "commercial", "industrial", "aerodrome", "cemetery", "hospital", "school", "stadium", "zoo"}
\item{\code{sport}}{Sport type for sports facilities}
}
}
\section{Buildings Layer Properties}{
\describe{
\item{\code{kind}}{Building type: "address", "building", "building_part"}
\item{\code{height}}{Building height in meters}
\item{\code{min_height}}{Base height for building parts}
\item{\code{addr_housenumber}}{Street address number}
}
}
\section{POIs Layer Properties}{
\describe{
\item{\code{kind}}{POI type: "cafe", "restaurant", "hospital", "school", "bank", "pharmacy", "hotel", etc.}
\item{\code{name}}{POI name}
\item{\code{cuisine}}{Cuisine type for restaurants}
\item{\code{religion}}{Religion for places of worship}
}
}
\section{Filter Examples}{
\preformatted{
# Major cities only
filter = "feature.props.kind_detail === 'city'"
# States/provinces
filter = "feature.props.kind === 'region'"
# Important places (low min_zoom = important)
filter = "feature.props.min_zoom <= 6"
# Large cities by population rank
filter = "feature.props.population_rank >= 10"
# Highways only
filter = "feature.props.kind === 'highway'"
# Parks
filter = "feature.props.kind === 'park'"
# Combine conditions
filter = "feature.props.kind_detail === 'city' && feature.props.min_zoom <= 8"
}
}
\references{
\url{https://docs.protomaps.com/basemaps/layers}
}
\seealso{
\code{\link{pmPaintRule}}, \code{\link{pmLabelRule}}
}

View file

@ -0,0 +1,54 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sample-tiles.R
\name{protomaps_sample_tiles}
\alias{protomaps_sample_tiles}
\title{Get Path to Sample PMTiles File}
\usage{
protomaps_sample_tiles(
region = "sf-bay",
cache_dir = NULL,
force_download = FALSE
)
}
\arguments{
\item{region}{Character. Region to download. Currently only "sf-bay"
(San Francisco Bay Area) is available. Default is "sf-bay".}
\item{cache_dir}{Character. Directory to cache the downloaded file.
Default uses \code{tools::R_user_dir()}.}
\item{force_download}{Logical. Force re-download even if cached.
Default is FALSE.}
}
\value{
Character. Path to the PMTiles file.
}
\description{
Returns the path to a sample PMTiles file for demos and testing.
On first use, downloads a small regional extract to the user's cache
directory.
}
\details{
The sample tiles are hosted on GitHub releases and downloaded on first use.
Subsequent calls use the cached file. The SF Bay Area extract is
approximately 10-15MB and covers the greater San Francisco region at all
zoom levels.
For production use, consider self-hosting your own PMTiles file. See
\code{vignette("getting-started")} for options.
}
\examples{
\dontrun{
library(leaflet)
library(protomapr)
# Use sample tiles for demos (downloads on first use)
leaflet() \%>\%
setView(lng = -122.4, lat = 37.8, zoom = 12) \%>\%
addProtomaps(url = protomaps_sample_tiles())
}
}
\seealso{
\code{\link{protomaps_clear_cache}}, \code{\link{protomaps_url}}
}

42
man/protomaps_url.Rd Normal file
View file

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addProtomaps.R
\name{protomaps_url}
\alias{protomaps_url}
\alias{protomaps_demo_url}
\title{Get Protomaps API tile URL}
\usage{
protomaps_url(api_key = NULL)
protomaps_demo_url(api_key = NULL)
}
\arguments{
\item{api_key}{Character. Your Protomaps API key. If NULL (default),
uses the \code{PROTOMAPS_API_KEY} environment variable.}
}
\value{
Character. URL template for the tile API.
}
\description{
Returns a URL template for the Protomaps tile API. Requires an API key,
which can be passed directly or set via the \code{PROTOMAPS_API_KEY}
environment variable.
Get a free API key (for non-commercial use) at \url{https://protomaps.com/}.
For commercial use or high traffic, consider self-hosting PMTiles files.
}
\examples{
\dontrun{
# Set your API key as an environment variable (recommended)
Sys.setenv(PROTOMAPS_API_KEY = "your-api-key-here")
leaflet() \%>\%
addProtomaps(url = protomaps_url())
# Or pass the key directly
leaflet() \%>\%
addProtomaps(url = protomaps_url(api_key = "your-api-key-here"))
}
}
\seealso{
\code{\link{set_protomaps_key}} for a convenient way to set the API key.
}

33
man/set_protomaps_key.Rd Normal file
View file

@ -0,0 +1,33 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addProtomaps.R
\name{set_protomaps_key}
\alias{set_protomaps_key}
\title{Set Protomaps API key}
\usage{
set_protomaps_key(api_key)
}
\arguments{
\item{api_key}{Character. Your Protomaps API key.}
}
\value{
Invisibly returns the API key.
}
\description{
Convenience function to set your Protomaps API key for the current session.
The key is stored in the \code{PROTOMAPS_API_KEY} environment variable.
For persistent storage, add to your \code{.Renviron} file:
\code{PROTOMAPS_API_KEY=your-key-here}
Get a free API key at \url{https://protomaps.com/}.
}
\examples{
\dontrun{
set_protomaps_key("your-api-key-here")
# Now protomaps_url() will work without arguments
leaflet() \%>\%
addProtomaps(url = protomaps_url())
}
}