Description Usage Arguments Details Value Author(s) Examples
Take some sp-class objects (SpatialPointsDataFrame, SpatialPolygonsDataFrame etc) and create an OpenLayers map using OpenStreetMap background data.
1 |
... |
Some layer objects |
title |
The map title. |
outputDir |
Where to put the html and data files. |
htmlFile |
The name of the html file. |
browse |
If TRUE, open R's default web browser on completion. |
All spatial data must be in EPSG:4326 coordinates - this is also WGS84, and is the most common lat-long system used by GPS and other web mapping systems.
The path to the HTML file. Open this in your favourite browser. You need a browser with good JavaScript and SVG support.
Barry Rowlingson
1 2 3 4 5 6 7 8 9 | # create a spatial points data frame from the state data:
statesp = data.frame(state.x77)
statesp$Name = row.names(statesp)
coordinates(statesp) = cbind(state.center$x,state.center$y)
# how to produce three layers:
osmMap(layer(statesp[state.center$x < -109,],name="state1",lstyle(fillColor="red")),
layer(statesp[state.center$x >= -109 & state.center$x < -84,],
name="state2",lstyle(fillColor="blue",fillOpacity=0.5)),
layer(statesp[state.center$x > -84,],name="state3"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.