Est-il possible d’afficher une polyligne avec deux couleurs différentes (par exemple: en fonction de la vitesse limite autorisée) dans la notice en utilisant brillant? Toute aide pourrait être très appréciée.
Réponses:
1 pour la réponse № 1Vous pouvez utiliser ce plugin: http://hgoebl.github.io/Leaflet.MultiOptionsPolyline/demo/
Vous devrez définir la vitesse de chaque point dans vos propriétés GeoJSON.
Ensuite, vous devez simplement ajouter ce code après:
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);
Pour la vitesse: https://github.com/hgoebl/Leaflet.MultiOptionsPolyline/blob/master/demo/js/demo.js#L59-L80