Description Usage Arguments Value References See Also Examples
This is the high-level function for creating a document that can be displayed in a Web browser to show a Google Map. This allows us to display geographical data on a Google Map that is interactive. We can add many overlay objects such as lines, paths and polygons and interactive markers.
In the future, we will be able to add images. We can also control different aspects of interaction.
1 2 3 4 5 6 7 8 | googleMapsDoc(code, center = c(0, 0), zoom = 1, file = NA,
scripts = character(), title = character(),
dims = c(750, 750), control = "GSmallZoomControl3D",
mapOpts = NULL,
key = getOption("GoogleMapsKey"), version = 3,
onload = "initialize()", canvas.id = "map_canvas",
template = system.file("templates", "template.html",
package = "R2GoogleMaps"))
|
code |
a character string/vector that specifies the essential
code for the function that creates the Google Map within the
document. Typically, this code is appended to generic code that
creates the map, centers it at the coordinates specified via
|
center |
a numeric vector giving the latitude and longitude at which the map should be centered |
zoom |
an integer giving the zoom level for when the map is first displayed. This should be between 1 and 20 inclusive. See the Google Maps API. |
file |
a character string giving the name of the file
that is to be created. If this is |
scripts |
a character vector giving either the names of JavaScript code files or the JavaScript code itself which are inserted into the HTML document. If these are file names, a reference to that file will be added. In the future, we will provide a mechanism that allows the caller of this function to control whether a reference is used or the contents of the files are added. |
title |
a string that is used for the title of the HTML document, appearing in the window frame |
dims |
a numeric/integer vector giving the number of pixels in
the horizontal and vertical orientations for the map canvas on which
the map is drawn and displayed. One can specify an individual value
but it must be a named vector, using either |
control |
a character vector giving the name of the type of
GControl to display on the map. This can be a partial match (see
|
mapOpts |
a named list providing named options that map to a
GMapOptions constructor/initializer. This can be used to specify
the |
key |
a character string giving the Google Maps API key to use when connecting to the Google Maps server. See registering an application in the Google Maps documentation. |
version |
an integer specifying the version of the Google Maps API to use. This currently should be either 2 or 3. |
onload |
the JavaScript call that is used to create the map when
the document is loaded. This is used as the value of the
|
canvas.id |
the name of the HTML element that is used to display the map. This is typically not specified, but if the HTML document is to have two or more maps displayed, one may want to control this. |
template |
the name of the file that contains the HTML code that acts as a template. |
If file
is a string, this is returned and the corresponding
file is created/overwritten with the generated HTML document.
Alternatively, if file
is NA
or an empty vector,
the generated HTML document is returned as an HTMLInternalDocument
object.
http://code.google.com/apis/maps/documentation/reference.html and http://code.google.com/apis/maps/documentation/index.html
http://www.omegahat.org/R2GoogleMaps/sampleDocs/sfcabs.html
1 2 3 4 5 6 7 | # Thanks to Markus Loecher's example.
plottingCode = "// ..." # need to put something of substance
googleMapsDoc(c("map.setUIToDefault();",
"map.enableGoogleBar();",
"map.addControl(new GSmallZoomControl3D());",
plottingCode
), mapOpts = list(googleBarOptions = c(style = "new")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.