我正在寻找有关获取 leafletR 包的基本示例以在浏览器中显示 map 的指导。使用最基本的示例, map 不会显示在浏览器中。我检查了 .html 和 .json 文件,它们存在并且格式正确。 Javascript 检查器显示此错误:
XMLHttpRequest cannot load file:///var/folders/_0/tdgf_k7x77qdn64_gk9ynljm0000gp/T/Rtmp6O4QZM/Fiji_Earthquakes/quakes.geojson. Received an invalid response. Origin 'null' is therefore not allowed access.
我在 Mac 上:OSX 10.7.5 RStudio 版本:0.98.857
代码
library(leafletR)
data(quakes)
# store data in GeoJSON file (just a subset here)
q.dat <- toGeoJSON(data=quakes[1:99,], dest=tempdir(), name="quakes")
# make style based on quake magnitude
q.style <- styleGrad(prop="mag", breaks=seq(4, 6.5, by=0.5), style.val=rev(heat.colors(5)), leg="Richter Magnitude", fill.alpha=0.7, rad=8)
# create map
q.map <- leaflet(data=q.dat, dest=tempdir(), title="Fiji Earthquakes", base.map="osm", style=q.style, popup="mag")
# view map in browser
browseURL(q.map)
预先感谢您的任何建议。
最佳答案
使用本地 Web 服务器打开 map 的快速解决方案是利用 RStudio 的 HTML 查看器。
rstudio::viewer(qmap)
https://stackoverflow.com/questions/23848536/
相关文章:
python - 如何将.html文件输出到.doc文件django
angularjs - 是否可以在模板 Angularjs 中输出整个范围?
visual-studio-2010 - Visual Studio : show all spec
ios - Cordova - 使用固定页眉和页脚滚动 (ios)
java - 在语言转换 java swing 应用程序中处理字符宽度
ruby-on-rails - 尝试使用 Devise 向我的用户模型添加外来关系,然后更新它
rabbitmq - Spring + RabbitMQ : Tracking progress o