Я использую пакет leafletR (http://cran.r-project.org/web/packages/leafletR/index.html), чтобы сделать апплет веб-апплет листовки, но не удалось загрузить 2 набора функций на одну и ту же карту.Проблемы с загрузкой 2 файлов GeoJSON в веб-карту листовки в R с использованием пакета leafletR
Как я понимаю, функция sheetlet() будет принимать только файлы GeoJSON одного типа геометрии.
У меня поэтому есть 2 отдельных файла GeoJSON, один с MultiPolygons и другой с точками.
Я смог получить MultiPolygons, чтобы сделать как choropleth с этим кодом:
#Load LeafletR
require(leafletR)
#Create quantiles
cuts <- round(quantile(UKpostcode_areas$data, probs = seq(0, 1, 0.20), na.rm = FALSE), 0)
cuts[1] <- 0 #We don't want any negative values, so let's make the first cut zero
#Fields to include in the popup
popup.1 <- c("name", "data")
#Graduated style based on an attribute
sty.1 <- styleGrad(prop = "data", breaks=cuts, right=FALSE, style.par="col", style.val=rev(heat.colors(6)), leg="Data", lwd=1)
#Create the map and load into browser
map <- leaflet(data = "map/UKpostcode_areas.geojson", dest = "map", style = sty.1, title = "UKpostcode_areas_choropleth", base.map= "osm", incl.data=TRUE, popup = popup.1)
Я также смог получить очки, чтобы сделать:
#Create new style and popup details for the 2nd layer
sty.2 <- styleSingle(col = "white", fill = "#2b83ba", fill.alpha = 1, rad = 3)
popup.2 <- c("name", "trust")
#Let's take a look at the map of hospitals
map2 <- leaflet(data="map/hospitals.geojson", dest = "map", style = sty.2, popup = popup.2, title = "hospitals", base.map = "osm", incl.data=TRUE, controls = "all")
browseURL(map2)
Однако, когда Я пытаюсь сделать как на одной и той же карте Листовка, он просто дает мне пустой экран:
#Now we can combine the 2 into 1 map, this is problematic, can't get it to work!
map3 <- leaflet(data = list("map/UKpostcode_areas.geojson", "map/hospitals.geojson"), style = list(sty.1, sty.2), dest = "map", title = "index", base.map= "osm", incl.data=TRUE, controls = "all")
browseURL(map)
Я подозреваю, что есть что-то не так с последними парами строк кода. Но я не могу понять, что.