从这里下载的世界边界geo.json。https://github.com/johan/world.geo.json
我正在尝试突出显示3个国家/地区(在世界地图视图中),并根据该国家/地区的项目数量以渐变颜色绘制它们。
这是我的步骤:
首先下载世界边界geo.json文件并将其作为底图读取; 然后我尝试在我的数据中突出显示国家多边形。然而事实证明,世界上所有国家都有着鲜明的色彩,并被3个国家的信息所标记。它是地理数据帧子集问题吗?
expect(jest.fn())[.not].toBeCalled()
jest.fn() value must be a mock function or spy.
Received:
function: [Function backButtonActions]
at Object.<anonymous> (test/js/spec/create/button-actions.test.js:64:50)
我期待这样的事情:
答案 0 :(得分:2)
这样就可以了!使用以下方法对WorldCountry进行子集:
data_Map <- WorldCountry[WorldCountry$id %in% data$Country, ]
Map <- leaflet(data_Map) %>% addTiles() %>% addPolygons()
答案 1 :(得分:0)
子集将带有WorldCountry $ name
data_Map <- WorldCountry[WorldCountry$name %in% data$Country, ]
Map <- leaflet(data_Map) %>% addTiles() %>% addPolygons(
fillColor = ~pal(data$Projects),
weight = 2,
opacity = 1,
color = 'white',
dashArray = '3',
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")
)