我试图在我的海图代码中包含印度地图

时间:2019-06-19 05:32:53

标签: highcharts

我正在使用以下代码,但由于地图不在列表中而出现错误

下面的代码我也使用了hcmap而不是hc_add_series_map,但是由于地图不在列表中,所以仍然会出错

`mudra_state <- mudra %>%
 group_by(State,Loan.Type) %>%
summarize(sum(Sanctioned.Amt),sum(Disbursement.Amt),sum(No.Of.Sanctions))

highchart() %>%
     hc_title(text = "Mudra Loans in India") %>%
     hc_subtitle(text = "Source: mudra.csv") %>%
 hc_add_series_map("https://raw.githubusercontent.com/codeforamerica/click_that_hood/master/public/data/india.geojson", mudra_state,
                       name  = c("State","Loan.Type"),
                       value = c("sum(Sanctioned.Amt)","sum(Disbursement.Amt)","sum(No.Of.Sanctions)"),
                       joinBy = c("woename", "State")) %>%
     hc_mapNavigation(enabled = T)`

错误:地图不是列表

1 个答案:

答案 0 :(得分:0)

我将使用注释,但是不能将格式化的代码粘贴到此处。如有必要,我将编辑我的答案。

我认为您无法像示例中那样获取地图。我可以通过这种方式获取您的地图:

library(highcharter)
indiageojson <- content(GET("https://raw.githubusercontent.com/codeforamerica/click_that_hood/master/public/data/india.geojson"))
indiageojson <- jsonlite::fromJSON(indiageojson)
indiageojson <- geojsonio::as.json(indiageojson)
highchart(type = "map") %>%
  hc_add_series(mapData = indiageojson)