r ggmap - 添加叠加在地图上的注释

r ggmap - add annotation superimposed on map

存在关于地图图例编辑的问题(),但不完全是我需要的。

如何使用 ggmap select 在地图中点并添加叠加在地图上的注释?取以下代码:

Map <- get_map(location = 'Santiago, Chile', zoom = 6, maptype = "terrain")
Map <- ggmap(Map)
Points <- data.frame(lon=c(-71.82718,-71.31263),lat=c(-34.36935,-34.29322))
Map_Points <- Map + geom_point(data = Points,aes(x=lon,y=lat,size=6))

现在我有了一张带有几个点的漂亮地图。如何在其中一个点附近写一些注释?

非常简单:

代码

library(ggrepel)                   # for the auto-repelling label
Map + 
    geom_point(data = Points, 
               aes(x = lon, y = lat),
               size = 3) +
    geom_label_repel(data = Points, 
                     aes(x = lon, y = lat, label = name),
                     size = 3,
                     vjust = -2,
                     hjust = 1)

数据

library(tmaptools)                 # for the geocode lookup
library(ggmap)
santiago_coords <- rbind(as.numeric(paste(geocode_OSM("Santiago, Chile")$coords))) 
Map <- get_map(location = santiago_coords, zoom = 6, maptype = "terrain")
Map <- ggmap(Map)
Points <- data.frame(lon=c(-71.82718,-71.31263),
                     lat=c(-34.36935,-34.29322),
                     name=c("Location One", "Location Two"))