是否有任何方法可以通过使用Shiny在传单中显示一种带有两种不同颜色(例如:基于道路速度限制)的多线线?任何帮助都可以高度赞赏。
您可以使用此插件:http://hgoebl.github.io/leaflet.multioptionspolyline/demo/
您必须定义Geojson属性中每个点的速度。
然后,您只需在以下内容之后添加此代码:
var myPolyline = L.multiOptionsPolyline(YourGeoJSONHere, {
multiOptions: {
optionIdxFn: function (latLng) {
var i,
speedThresholds = [5, 10, 15, 30];
for (i = 0; i < speedThresholds.length; ++i) {
if (latLng.alt <= speedThresholds[i]) {
return i;
}
}
return speedThresholds.length;
},
options: [
{color: '#0000FF'}, {color: '#0040FF'},
{color: '#0080FF'}, {color: '#00FFB0'}
]
},
weight: 5,
opacity: 0.9,
smoothFactor: 1
}).addTo(layerTrace);
速度:https://github.com/hgoebl/leaflet.multioptionspolyline/blob/master/master/demo/js/demo.js#l59-l59-l59-l80