2017-09-13 3 views

Répondre

0

Vous pouvez utiliser ce plugin: http://hgoebl.github.io/Leaflet.MultiOptionsPolyline/demo/

Vous devrez définir la vitesse pour chaque point dans vos propriétés GeoJSON.

Ensuite, il vous suffit d'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