Description Usage Arguments Value Author(s) Examples
This function is the workhorse of the package RgoogleMaps. It overlays plot on background image of map tile
1 2 3 4 5 6 7 8 9 10 |
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 |
zoom |
Google maps zoom level. optional if |
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 |
the map object is returned via invisible(MyMap)
Markus Loecher
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #The first step naturally will be to download a static map from the Google server. A simple example:
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.