ol_geom_text | R Documentation |
Function to create a Text layer to add to an OpenLayers Map object.
ol_geom_text(point.obj, label, name = NULL, toggle.control = FALSE, label.params = list(), tooltip = NULL, tooltip.params = list())
point.obj |
SpatialPointsDataframe, SpatialPoints, or a matrix containing columns of point longitudes and latitudes, respectively. |
label |
character vector of text labels to put at points. |
name |
character Layer name. |
toggle.control |
logical indicating whether this layer will have a visibility toggle. |
label.params |
named list (e.g., |
tooltip |
character vector of point feature tooltip popups. |
tooltip.params |
named list (e.g., |
This function stores the data required to generate an OpenLayers
vector layer with text features using Point
geometries. It does not enable aesthetic mappings to variables.
A list object of class Layer.Text
.
label.params
The label.params
parameter provide direct access to OpenLayers
feature text styling (see OpenLayers Documentation).
Multiple values for any of these properties is not supported.
The following ol/style/Text properties are supported:
font | character label font CSS string |
offsetX | numeric label x-offset |
offsetY | numeric label y-offset |
rotation | numeric label rotation |
textAlign | character label text horizontal alighment |
textBaseline | character label text vertical alignment |
stroke_color | character text color |
fill_color | character text fill color |
ol_map
,
ol_geom_point
text.pts <- matrix( c( -101.5, 39.2, -101.1, 54, -101.1, 21.4 ), byrow=TRUE, ncol=2 ) text.labels <- c("USA","Canada","Mexico") mymap <- ol_map( center=c(-100,25), zoom=3 ) + oceanbase() + ol_geom_text( text.pts, text.labels, toggle.control=TRUE, label.params=list( font="16px sans-serif", stroke_color="#FF0000", fill_color="#FFFFFF00" ) ) ## Not run: # Write to file and view in browser ol_map2HTML(mymap, "textmap.html") browseURL("textmap.html") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.