This function is the workhorse of the package RgoogleMaps. It overlays plot on background image of map tile
PlotOnStaticMap(MyMap, lat, lon, destfile, zoom =NULL, size, GRAYSCALE =FALSE, add =FALSE, FUN = points, mar = c(0,0,0,0), NEWMAP =TRUE, TrueProj =TRUE, axes =FALSE, atX =NULL, atY =NULL, verbose =0,...)
Arguments
MyMap: optional map object
lat: latitude values to be overlaid
lon: longitude values to be overlaid
destfile: File to load the map image from or save to, depending on whether MyMap was passed.
zoom: Google maps zoom level. optional if MyMap is passed, required if not.
size: desired size of the map tile image. defaults to maximum size returned by the Gogle server, which is 640x640 pixels
GRAYSCALE: Boolean toggle; if TRUE the colored map tile is rendered into a black & white image, see RGB2GRAY
add: start a new plot or add to an existing
FUN: plotting function to use for overlay; typical choices would be points and lines
mar: outer margin in plot; if you want to see axes, change the default
NEWMAP: load map from file or get it "new" from the static map server
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
axes: overlay axes ?
atX: numeric; position of ticks on x-axis; if missing, axTicks is called for nice values; see axis
atY: numeric; position of ticks on y-axis; if missing, axTicks is called for nice values; see axis
verbose: level of verbosity
...: further arguments to be passed to FUN
Returns
the map object is returned via invisible(MyMap)
Author(s)
Markus Loecher
Examples
#The first step naturally will be to download a static map from the Google server. A simple example:if(0){ lat = c(40.702147,40.711614,40.718217); lon = c(-74.015794,-74.012318,-73.998284); center = c(mean(lat), mean(lon)); zoom <- min(MaxZoom(range(lat), range(lon)));#this overhead is taken care of implicitly by GetMap.bbox(); MyMap <- GetMap(center=center, zoom=zoom,markers = paste0("&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"); tmp <- PlotOnStaticMap(MyMap, lat = lat, lon = lon, destfile ="MyTile1.png", cex=1.5,pch=20, col=c('red','blue','green'), add=FALSE);#and add lines: PlotOnStaticMap(MyMap, lat = c(40.702147,40.711614,40.718217), lon = c(-74.015794,-74.012318,-73.998284), lwd=1.5,col=c('red','blue','green'), FUN = lines, add=TRUE)}