View source: R/write_functions.R
ol_map2Strings | R Documentation |
Assigns Ol.Map HTML content to list.
ol_map2Strings(ol.map.obj, width = NULL, height = NULL, ol.source.url = NULL, nga.olsource = FALSE, map.heading = NULL, map.note = NULL)
ol.map.obj |
Ol.Map object to be exported. |
width |
numeric or character CSS value width of map container. |
height |
numeric or character CSS value height of map container. |
ol.source.url |
character string containing the url to the OpenLayers
javascript library. Ignored if nga.olsource is |
nga.olsource |
logical. |
map.heading |
character heading to be placed over map in html h1 tag. |
map.note |
character note placed in html paragraph (<p>) tag centered under map container. |
Ol.Map object HTML is exported to a list object that can be deployed in a variety of applications or server environments. See exmaples for a minimal example using RShiny. This method does not currently support adding multiple maps to the same web page, as javascript variable names would be replicated.
list object with the following character elements:
$head.meta.IE.compatibility | HTML meta tag for IE compatability viewing. |
$head.script | HTML script block including or sourcing the OpenLayers
Javascript library (see ol.map.obj ). |
$style | CSS code for styling the map and legends. |
$body.html | HTML map and legend containers, and associated elements. |
$body.script | Javascript code writing the layer and map objects. |
ol_map
,
ol_map2HTML
,
heatmap.pts <- matrix( c( rnorm(100,-80.385,1), #Miami Longitudes rnorm(100,-117.1611,3), #San Diego Longitudes rnorm(100,25.782618,1), #Miami Latitudes rnorm(100,32.7157,3) # San Diego Latitudes ),ncol=2 ) mymap <- ol_map( center=c(-98.5,28.5), zoom=4 ) + streetmap() + ol_geom_heatmap( heatmap.pts, name="Random Heatmap", toggle.control=TRUE, opacity=0.25 ) ## The following line will create image files ## as needed for point layers and legends. ## None are required in this example. HTML.strings <- ol_map2Strings( mymap, nga.olsource=FALSE, map.note="Heatmap of random points centered on Miami and San Diego." ) ## Minimal shiny example ## Not run: library(shiny) ui <- shinyUI( fluidPage( #Add OpenLayers Javascript source & CSS to head tags$head( HTML(HTML.strings[[1]]) HTML(HTML.strings[[2]]), tags$style(HTML(HTML.strings[[3]])) ), titlePanel("Random Heatmap"), mainPanel( tags$div(HTML(HTML.strings[[4]])) ), tags$script(HTML(HTML.strings[[5]])) ) ) server <- function(input,output){ } shinyApp(ui=ui,server) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.