如@TimSalabim的评论中所述,请尝试使用带有图标的标记。对于它的乐趣:
library(leaflet)
library(dplyr)
library(readr)
download.file("https://data.melbourne.vic.gov.au/api/views/fp38-wiyy/rows.csv?accessType=DOWNLOAD", tf <- tempfile(fileext = ".csv"))
set.seed(1)
td <- read_csv(tf) %>%
sample_n(500) %>%
mutate(Genus = factor(ifelse(Genus %in% c("Quercus", "Corymbia", "Platanus", "Ulmus", "Eucalyptus"), Genus, "other")))
m <- leaflet(td) %>%
addTiles(urlTemplate = '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>')
myicons <- iconList(
Quercus = makeIcon("http://i.stack.imgur.com/okgqd.png",iconWidth = 8, iconHeight = 8),
Corymbia = makeIcon("http://i.stack.imgur.com/nfGZT.png",iconWidth = 8, iconHeight = 8),
Platanus = makeIcon("http://i.stack.imgur.com/J47uj.png",iconWidth = 8, iconHeight = 8),
Ulmus = makeIcon("http://i.stack.imgur.com/idnpO.png",iconWidth = 8, iconHeight = 8),
Eucalyptus = makeIcon("http://i.stack.imgur.com/6GzzW.png",iconWidth = 8, iconHeight = 8),
other = makeIcon("http://i.stack.imgur.com/x0bOg.png",iconWidth = 8, iconHeight = 8)
)
m %>% addMarkers(~Longitude, ~Latitude, popup=paste("Name:", td$`Common Name`),
icon = ~myicons[Genus])
给出了类似:
您可以使用自己的标记,你只需要该'.png's。请参阅[这里](https://rstudio.github.io/leaflet/markers.html)。有一个问题,你是如何让小册子有很多点的? – TimSalabim
您可以使用'addCircles()'函数并查看本教程 - [http://trendct.org/2015/06/26/tutorial-how-to-put-dots-on-a-leaflet-map -with-R /]。希望这可以帮助。 –
TimSalabim,我曾经在此工作过一段时间,并能够绘制一大堆点https://github.com/rstudio/leaflet/pull/174#issuecomment-135988304 – timelyportfolio