This is a demo of using rCharts
to create a Leaflet
map using KML. It requires you to install the latest dev
branch of rCharts
, which can be done using install_github("rCharts", "ramnathv", ref = "dev")
. The code to reproduce this chart is shown below
# download kml example file
require(downloader)
download(
url = "http://harrywood.co.uk/maps/examples/leaflet/mapperz-kml-example.kml",
destfile = "mapperz-kml-example.kml"
)
# initialize leaflet chart and add kml
L1 <- Leaflet$new()
L1$addKML("mapperz-kml-example.kml")
L1$save('index.html', cdn = TRUE)
Note that you will not be able to view the map as static HTML. So fire up a local server from the same directory where you saved your html file and the kml file.
$ python -m SimpleHTTPServer 8000
and navigate to http://localhost:8000/index.html
Modified http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js to a secure url
Modified http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js to a secure url
https://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js
https://rawgithub.com/leaflet-extras/leaflet-providers/gh-pages/leaflet-providers.js
https://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js