我正在尝试使用R中的leaflet软件包来制作交互式地图。一个月前,一切都正常,但现在我的地图出现了,但无法显示标记。我尝试使用我在网上找到的一个简单的例子,但这个问题也存在。我尝试更新了R,R studio和所有的软件包。我还尝试了github开发版的leaflet,但无济于事。这是在.Rmd文件中运行的(也尝试了在普通脚本中运行)。如果有人有任何想法,请告诉我,谢谢!我的代码:
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
我的输出:
我从这个网站上获取了代码,显示了它应该是什么样子:https://rstudio.github.io/leaflet/
会话信息:
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[3] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[3] stats graphics grDevices utils datasets methods base
other attached packages:
[3] leaflet_2.1.0 lindia_0.9 ggannotate_0.1.0.900 shiny_1.7.1 esquisse_1.1.0 readxl_1.3.1
[7] haven_2.4.3 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.8 purrr_0.3.4 readr_2.1.2
[13] tidyr_1.2.0 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
loaded via a namespace (and not attached):
[3] colorspace_2.0-3 ellipsis_0.3.2 rio_0.5.29 rprojroot_2.0.2 parameters_0.17.0 fs_1.5.2
[7] mc2d_0.1-21 rstudioapi_0.13 farver_2.1.0 remotes_2.4.2 ggrepel_0.9.1 DT_0.21
[13] fansi_1.0.2 mvtnorm_1.1-3 lubridate_1.8.0 xml2_1.3.3 splines_4.1.3 cachem_1.0.6
[19] knitr_1.37 pkgload_1.2.4 zeallot_0.1.0 jsonlite_1.8.0 broom_0.7.12 dbplyr_2.1.1
[25] ggdist_3.1.1 clipr_0.8.0 compiler_4.1.3 httr_1.4.2 backports_1.4.1 assertthat_0.2.1
[31] Matrix_1.4-0 fastmap_1.1.0 cli_3.2.0 later_1.3.0 prettyunits_1.1.1 htmltools_0.5.2
[37] tools_4.1.3 ggstatsplot_0.9.1 gtable_0.3.0 glue_1.6.2 Rcpp_1.0.8.3 cellranger_1.1.0
[43] jquerylib_0.1.4 vctrs_0.3.8 nlme_3.1-155 crosstalk_1.2.0 insight_0.16.0 xfun_0.30
[49] brio_1.1.3 ps_1.6.0 testthat_3.1.2 openxlsx_4.2.5 rvest_1.0.2 mime_0.12
[55] miniUI_0.1.1.1 lifecycle_1.0.1 devtools_2.4.3 MASS_7.3-55 scales_1.1.1 hms_1.1.1
[61] promises_1.2.0.1 rematch2_2.1.2 RColorBrewer_1.1-2 yaml_2.3.5 curl_4.3.2 memoise_2.0.1
[67] gridExtra_2.3 datamods_1.2.0 sass_0.4.0 reshape_0.8.8 stringi_1.7.6 paletteer_1.4.0
[73] bayestestR_0.11.5 desc_1.4.1 pkgbuild_1.3.1 zip_2.2.0 rlang_1.0.2 pkgconfig_2.0.3
[79] distributional_0.3.0 lattice_0.20-45 patchwork_1.1.1 htmlwidgets_1.5.4 labeling_0.4.2 processx_3.5.2
[85] tidyselect_1.1.2 plyr_1.8.6 magrittr_2.0.2 R6_2.5.1 generics_0.1.2 DBI_1.1.2
[91] pillar_1.7.0 foreign_0.8-82 withr_2.5.0 mgcv_1.8-39 datawizard_0.3.0 performance_0.8.0
[97] modelr_0.1.8 crayon_1.5.0 WRS2_1.1-3 shinyWidgets_0.6.4 utf8_1.2.2 correlation_0.8.0
[103] tzdb_0.2.0 usethis_2.1.5 grid_4.1.3 data.table_1.14.2 callr_3.7.0 reprex_2.0.1
[109] digest_0.6.29 xtable_1.8-4 httpuv_1.6.5 statsExpressions_1.3.0 munsell_0.5.0 viridisLite_0.4.0
leaflet
似乎没有按预期运行...显然我们不是唯一面临这个问题的人,因为两天前在github上已经有人报告了这个问题...所以,请在这里找到链接,以防解决方案首先出现在github上。干杯。 - lovaleryleaflet
中得到解决。因此,您现在可以从CRAN
升级leaflet
库到版本2.1.1
,它将正常工作。干杯。 - lovalery