啊,隔了一年多再看这篇文章,真得好多细节都不完善呐。
在第3.5.5小节中调用的“China2”地图,其实是在3.5.2节中通过 e_map_register 函数注册好的,所以后面直接用了。如果第3.5.5小节独立写的话,应如下:
library(echarts4r)
china_map <- jsonlite::read_json("https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json")
df <- data.frame(
lat = c(39.9109, 31.2359, 22.5484),
lon = c(116.4133, 121.4805, 114.0645),
city = c("北京", "上海", "深圳"),
value = c(10, 20, 30)
)
df |>
e_charts(lon) |>
e_map_register("China2", china_map) |>
e_geo(map = "China2") |>
e_scatter(lat, value, coord_system = "geo", scale = NULL)