如何为热图添加动态图例?

时间:2019-05-09 22:41:43

标签: javascript dynamic leaflet legend heatmap

我有一个使用传单加热插件工作的动态热图。https://github.com/Leaflet/Leaflet.heat/tree/gh-pages/dist 可以使用此插件制作动态渐变图例吗?

//create heat map
function createHeatMap(pollen){

    var locations = pollen.features.map(function(row) {
      // the heatmap plugin wants an array of each location
      var location = row.geometry.coordinates.reverse();
      location.push(0.9);
      return location; // [50.5, 30.5, 0.2], [lat, lng, intensity]
    });

      var heat = L.heatLayer(locations, { 
       minOpacity: 0.3,
       radius: 20,
        blur:10,
        maxZoom:5,
        max:100,
       gradient: {
           0.1: 'purple',
           0.2: 'cyan',
           0.3: '#2b83ba',
           0.4: 'green',
           0.6: 'yellow',
           0.8: 'orange',
           0.9: '#d7191c',
           1: 'red'
       } 
   });

    map.addLayer(heat);

};

没有图例的当前热图

0 个答案:

没有答案