Learn R Programming

RgoogleMaps (version 1.1.9.15)

TextOnStaticMap: plots text on map

Description

TextOnStaticMap draws the strings given in the vector labels at the coordinates given by x and y on a map. y may be missing since xy.coords(x,y) is used for construction of the coordinates.

Usage

TextOnStaticMap(MyMap, lat, lon, labels = seq_along(lat), TrueProj = TRUE, FUN = text, add = FALSE, verbose = 1,...)

Arguments

MyMap
map image returned from e.g. GetMap()
lat
latitude where to put text.
lon
longitude where to put text.
labels
a character vector or expression specifying the text to be written. An attempt is made to coerce other language objects (names and calls) to expressions, and vectors and other classed objects to character vectors by
TrueProj
set to FALSE if you are willing to accept some degree of inaccuracy in the mapping. In that case, the coordinates of the image are in lat/lon and the user can simply overly points/lines/axis without worrying about projections
FUN
overlay function, typical choice would be text
add
add to existing map ?
verbose
level of verbosity
...
further arguments passed to text

Value

See Also

PlotOnStaticMap text

Examples

Run this code
lat = c(40.702147,40.718217,40.711614);
  lon = c(-74.012318,-74.015794,-73.998284);
  center = c(mean(lat), mean(lon));
  zoom <- min(MaxZoom(range(lat), range(lon)));
  
  MyMap <- GetMap(center=center, zoom=zoom,markers = '&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284', destfile = "MyTile1.png");
 
  TextOnStaticMap(MyMap, lat=40.711614,lon=-74.012318, "Some Text", cex=2, col = 'red')

Run the code above in your browser using DataLab