107 lines
3.2 KiB
R
107 lines
3.2 KiB
R
% 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)
|
|
)
|
|
}
|
|
|
|
}
|