ol_geom_icon: OpenLayers Icon Layer

View source: R/layer_icon.R

ol_geom_iconR Documentation

OpenLayers Icon Layer

Description

Function to create a point-icon layer to add to an OpenLayers Map object.

Usage

ol_geom_icon(point.obj, src.img = NULL, mapping = ol_aes(),
  name = NULL, df = NULL, toggle.control = FALSE,
  icon.size.scalar = "autoscale", src.img.width = NULL,
  target.icon.width = 30, size.scale.lims = c(0.5, 1.25),
  label = NULL, label.params = list(), tooltip = NULL,
  tooltip.params = list())

Arguments

point.obj

SpatialPointsDataframe, SpatialPoints, or a matrix containing columns of point longitudes and latitudes, respectively.

src.img

character vector of image file paths.

mapping

list created by ol_aes. Used for aestheic mapping.

name

character Layer name.

df

data.frame with same number of rows as point.obj coordinate matrix.

toggle.control

logical indicating whether this layer will have a visibility toggle.

icon.size.scalar

numeric scalar vector or 'autoscale'. The width of the icon on the map will be scaled by this input from the original image width. The default 'autoscale' uses the png, jpeg, or tiff package to scale each image to target.icon.width.

src.img.width

numeric vector of widths of user-supplied images, in pixels. If icon.size.scalar is not supplied and src.img.width is not provided, image widths will be detected using the png, jpeg, or tiff package.

target.icon.width

numeric desired width of icons on map, in pixels. Only used if icon.size.scalar is 'autoscale'.

size.scale.lims

numeric vector containing the minimum and maximum image scaling for size aesthetic mappings. A value of 1 results renders the image at the default size, determined by target.icon.width or icon.size.scalar.

label

character vector of point feature labels.

label.params, tooltip.params

named lists (e.g., list(property=value)) of label and tooltip position and format parameters. See ol_geom_polygon documentation.

tooltip

character vector of point feature tooltip popups.

Details

This function stores the data required to generate an OpenLayers vector layer with features using Point geometries and user-supplied point icons.

Value

A list object of class Layer.SpatialIcon.

Aesthetics

  • iconimage

  • iconsize

See Also

ol_map, ol_geom_polygon, ol_geom_circle, ol_geom_line, ol_geom_point

Examples

some.r.servers <- matrix(
    c(
        144.964,-37.798,
        -122.920,49.278,
        121.494,31.307,
        25.083,35.307,
        -21.930,64.149,
        11.877,45.407,
        -99.200,19.345,
        5.322,60.388,
        -8.224,39.400,
        -8.616,41.147,
        -73.953,40.768,
        20.304,63.821,
        8.548,47.376,
        33.031,35.247,
        -78.938,36.001,
        -123.279,44.564,
        -96.797,32.777
    ),
    byrow=TRUE,
    ncol=2
)
r.server.names <- c(
    'School of Mathematics and Statistics, University of Melbourne',
    'Simon Fraser University, Burnaby',
    'Shanghai University',
    'University of Crete',
    'Marine Research Institute',
    'University of Padua',
    'Instituto Tecnologico Autonomo de Mexico',
    'University of Bergen',
    'RadicalDevelop, Lda',
    'University of Porto',
    'Four Dots',
    'Academic Computer Club, UmeƄ University',
    'ETH Zurich',
    'Middle East Technical University Northern Cyprus Campus, Mersin',
    'Duke University, Durham, NC',
    'Oregon State University',
    'Revolution Analytics, Dallas, TX'
)
r.icon <- "https://www.r-project.org/Rlogo.png"
## If width is not provided image must be local
## and png package must be installed.
r.icon.width <- 200 
r.map <- ol_map(
    center=c(-100,30),
    zoom=3
) + 
    streetmap()+
    ol_geom_icon(
        some.r.servers,
        r.icon,
        name="R Servers",
        icon.size.scalar='autoscale',
        src.img.width=r.icon.width,
        toggle.control=TRUE,
        tooltip=r.server.names
) 
## Not run: 
# Save as HTML and open in browser
ol_map2HTML(r.map,'R-servers.html')
browseURL("R-servers.html")

## End(Not run)

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