Description Usage Arguments Value Author(s) Examples
These functions provide access to the HTML and JavaScript code that provide templates for creating a Web page with a Google Earth (GE) plugin instance embedded within it. The templates are provided as part of the RKML package and need to be customized in different ways to present the plugin and text and controls the author desires. While most of the content is context-specific, the templates provide the basic framework which can be easily customized and facilitate the initial work which can be hard to remember.
setAPIKey
inserts the authors own Google Earth API key
into the HTML document so that the basic GE code can be loaded.
It uses the HTML document we provide in the package by default, but
an alternative can be provided by the author. It will replace any
existing key, so can be used to customize a page found on the Web, for
example.
copyPluginJSCode
retrieves the template JavaScript code for the
plugin and either writes it to a file or returns it as text.
This function can also modify the code to load a KML document into the
GE plugin instance.
1 2 3 4 5 6 7 8 9 10 11 | setAPIKey(key = getOption("GoogleEarthAPIKey", Sys.getenv("GOOGLE_EARTH_API_KEY")),
doc = system.file("pluginTemplate", "gePluginTemplate.html", package = "RKML"))
copyPluginJSCode(to = "geInitialization.js", kml = character(),
multipleGEs = FALSE,
source = system.file("pluginTemplate",
if(multipleGEs)
"geMultiInitialization.js"
else
"geInitialization.js",
package = "RKML"))
|
key |
a string giving the Google Earth API key for the particular
host on which the document will be made available. Each key is
specific to a particular domain.
You can obtain a key for free at
http://code.google.com/apis/maps/signup.html.
The caller can specify this explicitly. However, it is often more
convenient
to retrieve it from R's global options, using the option name
|
doc |
a string giving the name of the HTML file to use as the
template HTML for the Web page. If this does not alreay have a
script element in the head of the document to load the GE code,
|
to |
the name of the file to write the code to. This can be
|
kml |
a character vector giving the names of one or more KML
files or URLs that are to be loaded into the Google Earth plugin
instance(s). These are added to the initialization callback that is
invoked by JavaScript when the GE instance has been created.
Currently, we load them all into the same GE if |
source |
a string giving the name of the file containing the JavaScript code. |
multipleGEs |
a logical value that is only used if |
setAPIKey
returns a parsed XML docment.
You can process this further and then write it to a file
using saveXML
.
copyPluginJSCode
either writes the JavaScript
code to a file (specified by to
) or
returns the code as a character vector.
Duncan Temple Lang
1 2 3 4 5 6 7 8 9 10 11 12 | doc = setAPIKey("ABCDEF")
saveXML(doc, tempfile())
txt = copyPluginJSCode(NA, "http://www.omegahat.org/RKML/JSM2011/tas1970.kml")
txt = copyPluginJSCode(tempfile(), "http://www.omegahat.org/RKML/JSM2011/tas1970.kml")
base = "http://www.omegahat.org/RKML/JSM2011/imageAnimation"
docs = c(ge.timeslice = "timeslice_current.kml",
ge.RCM = "gcmrcm_current.kml")
txt = copyPluginJSCode(NA, structure(sprintf("%s/%s", base, docs),
names = names(docs)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.