如何将线段添加到 google 地图

How to add lines segments to a google map

如何使用 rbokeh 包在 gmap 中的两点之间添加线段。

例如,下面的代码绘制点但不添加线段。

library(rbokeh)
pts <- data.frame(lat=c(40.73, 40.72), lng=-74)
gmap(lat = 40.73306, lng = -73.97351, zoom = 14, width = 680, height = 600) %>%
         ly_points(x=lng, y=lat, data = pts, col = "red")  %>%
         ly_segments(x0=-74, x1=-74, y0=40.72, y1=40.73, color="red", width=2)

您必须使用 ly_lines() 向绘图添加线条。 在 ly_points.

之前添加 ly_lines(x=lng, y=lat, data=pts) %>%