ol_scale_iconimage_discrete: Icon Image Scale

View source: R/scales.R

ol_scale_iconimage_discreteR Documentation

Icon Image Scale

Description

Map icon images to discrete variable values.

Usage

ol_scale_iconimage_discrete(icon.img.vector = NULL, name = NULL,
  na.img.src = NULL, ordered.values = NULL, display = FALSE,
  icon.width = NULL)

Arguments

icon.img.vector

character named vector of the form c(value=image.path). If NULL, a default mapping is assigned to the images available in the layer.

name

character the scale name.

na.img.src

character image path assigned to unrecognized or NA values.

ordered.values

character, numeric, or factor vector giving the ordering for the legend display. If NULL, the ordering from icon.img.vector is used.

display

logical indicating whether to draw the scale for output in the HTML. If TRUE, a bitmap will be created and sourced in the HTML in one or more img tags.

icon.width

numeric width(s) of icons for the legend display only. Icon widths for the map overlay are defined in ol_geom_icon.

Details

This method maps OpenLayers point (icon) feature images to discrete variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with an "iconimage" mapping to a numeric, character, or factor variable. If no such layer exists, attempts to add this type of scale will result in a warning.

Value

list of class Scale.IconImage.Discrete.

See Also

ol_map, ol_geom_icon,

Examples

freebsd.icon <- "https://www.freebsd.org/gifs/daemon-phk.png"
freebsd.icon.width <- 191
r.icon <- "https://www.r-project.org/Rlogo.png"
r.icon.width <- 200
loc.df <- data.frame(
    lon=c(
        -73.953,
        -78.938,
        -74.007
    ),
    lat=c(
        40.768,
        36.001,
        40.708
    ),
    type=c(
        "R",
        "R",
        "BSD"
    )

)
icon.map <- ol_map(
    center=c(-75,38),
    zoom=5
) + 
    streetmap()+
    ol_geom_icon(
        loc.df[,1:2],
        c(r.icon,freebsd.icon),
        mapping=ol_aes(iconimage=type),
        df = loc.df,
        name="Some Open Source Locations",
        icon.size.scalar='autoscale',
        src.img.width=c(r.icon.width,freebsd.icon.width),
        toggle.control=TRUE
) +
    ol_scale_iconimage_discrete(
    c(R=r.icon,BSD=freebsd.icon),
    display=TRUE
)
## Not run: 
# Oave as HTML and open in browser
ol_map2HTML(
  icon.map,
  'servers.html'
)
browseURL("servers.html")

## End(Not run)

cemarks/ROpenLayers documentation built on March 31, 2022, 12:05 p.m.