【发布时间】:2015-01-22 15:51:51
【问题描述】:
我在 R 中有一张传单地图,里面有很多 LineStrings。线条默认为蓝色,具有一定的粗细。我想更改线条颜色并使粗细取决于权重变量。我通过读取 geojson 文件来创建地图。将“样式”部分直接添加到 geojson 中的每个线串功能不起作用。这是我的地图 R 代码:
colchoice = "red"
ptl_str = paste("#! function(feature, latlng){
return L.circleMarker(latlng, {
radius: feature.properties.radius || 5,
fillColor: feature.properties.fillColor || '", colchoice, "',
color: '#000',
weight: 1,
fillOpacity: 0.8
})
} !#", sep="")
m <- Leaflet$new()
m$setView(c(38.892682, -77.031681), zoom = 12)
m$geoJson(geojson,
onEachFeature = "#! function(feature, layer){
layer.bindPopup(feature.properties.popup)
} !#",
pointToLayer = ptl_str)
m
这成功地将地图上的点格式化为点。但现在我也想以不同的方式格式化这些行。我很感激任何帮助。谢谢!
【问题讨论】: