Change color of leaflet line accordingly with a vector

萝らか妹 提交于 2020-01-04 03:55:13

问题


Is there anyway to change the color of leaflet line base on the value of some variable? I google it, and found this link.

However, I was wondering if there is a simple way to do it with leaflet in R. I tried something like:

data <- data.frame(long = runif(40,-10,10), lat = runif(40,50,60), speed = runif(40,0,100))
leaflet(data) %>% addTiles() %>% addPolylines(lng = ~long, lat = ~lat, color = ~speed)

but, it shows only one color.

来源:https://stackoverflow.com/questions/40948167/change-color-of-leaflet-line-accordingly-with-a-vector

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!