I'm trying to take a data frame:
lat lng active
122.536226 37.86047 green
122.536422 37.860303 green
122.536688 37.860072 red
...
and create a map, using RgoogleMaps, with line segments (or lines?) that are from row 1 to row 2, with the color in the 'active' column. My map just shows green and I'm not sure why. Here's the code I've written:
center <- c(mean(all_lat,na.rm=TRUE), mean(all_lng,na.rm=TRUE))
latRange = range(c(all_lat),finite=TRUE)
lngRange = range(c(all_lng),na.rm=TRUE, finite=TRUE)
zoom <- min(MaxZoom(latRange,lngRange))
mymap <- GetMap(center=center, zoom=zoom)
# show the basic map
PlotOnStaticMap(mymap,lat=c(mean(all_lat)),lon=c(mean(all_lng)), cex=0.5)
# add line segments
PlotOnStaticMap(mymap,lat=segs$lat,lon=segs$lng,col=segs$active,
FUN=lines,add=TRUE)
Suggestions?