[英]R Leaflet doesn't add all markers
I'm trying to follow the example in the link below to create a map with all the markers 我正在尝试按照以下链接中的示例创建包含所有标记的地图
Tutorial: How to put dots on a Leaflet map with R 教程:如何使用R在单张地图上放置点
The source file is below 源文件在下面
https://www.dropbox.com/s/az1yolknqwoxhb4/test_file.csv?dl=0 https://www.dropbox.com/s/az1yolknqwoxhb4/test_file.csv?dl=0
And the code that I tried 和我尝试过的代码
library(dplyr)
library(leaflet)
test_map <- read.csv("test_file.csv", header = TRUE, stringsAsFactors = FALSE)
m <- leaflet(test_map) %>% addTiles('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>')
m %>% setView()
m %>% addCircles(~long, ~lat,
popup=test_map$index,
weight = 3,
color="#ffa500", stroke = TRUE, fillOpacity = 0.8)
I was able to create the map 我能够创建地图
However, the map only shows a fraction of points, since the data I have has locations all over Canada. 但是,该地图仅显示了一部分点,因为我拥有的数据在加拿大各地都有。 When I tried to sub-select a city say like Toronto then some of the missing points shows up.
当我尝试子选择一个城市时,例如多伦多,然后会出现一些缺失点。
I'm not sure if i'm doing anything wrong or if this is a bug.I wonder if there's anyway for me to fix this problem or is there an alternative way to achieve a similar map? 我不确定自己做错了什么还是Bug。我想知道是否有办法解决这个问题,或者是否有替代方法可以实现类似的地图?
Thank you :) 谢谢 :)
There are NA values in test_map variable. test_map变量中有NA值。
add 加
test_map <- na.omit(test_map)
after reading csv. 看完csv后。
By this method i have more markers than your image. 通过这种方法,我比您的图像拥有更多的标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.