基本上我所拥有的是一张可以点击所有zipcodes的地图。每当我点击特定的邮政编码区域时,我会弹出一个弹出窗口,这个弹出窗口会显示学校的名称和等级。 我现在的问题是,1个邮政编码上有超过1所学校,我想在弹出窗口中显示每个邮政编码的所有学校。
shape_and_data <- merge(zipcode, aantal_hyp, by.x="PC4", by.y="ZIPCODE_SCHOOL", duplicateGeoms=TRUE, multiple = TRUE)
#way to make colorpalletes
pal <- colorQuantile("YlGn", NULL, n = 5)
state_popup <- paste0("<strong>Schoolnaam: </strong>",
shape_and_data$INSTELLINGSNAAM_VESTIGING,
"<br><strong>Quasi cito : </strong>",
shape_and_data$quasicito)
leaflet(data = shape_and_data) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = ~pal(GEMEENTENUMMER),
fillOpacity = 0.8,
color = "#BDBDC3",
weight = 1,
popup = state_popup)
state_popup <- paste0("<strong>Schoolnaam: </strong>",
区域是弹出窗口,您可以看到它只打印出1个学校名称。
答案 0 :(得分:1)
尝试引用leaflet()调用中的变量:
leaflet(data = shape_and_data) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = ~pal(GEMEENTENUMMER),
fillOpacity = 0.8,
color = "#BDBDC3",
weight = 1,
popup = paste("<strong>Schoolnaam: </strong>",
shape_and_data$INSTELLINGSNAAM_VESTIGING,
"<br><strong>Quasi cito : </strong>",
shape_and_data$quasicito))