简体   繁体   English

颜色渐变不起作用 leaflet.JS

[英]the color gradient doesn't work leaflet.JS

Sorry for asking again, I'm trying to implement a heatmap to Leaflet map but for some reason it seems all data points have the same color and there is no color gradient.抱歉再次询问,我正在尝试对 Leaflet map 实施热图,但由于某种原因,似乎所有数据点都具有相同的颜色并且没有颜色渐变。

The min value of data is 565 and max is 2455, there's about 900000+ line of data.数据的最小值为565,最大值为2455,大约有900000+行数据。 This is what I get all data shown in red这就是我得到的所有数据都以红色显示

这就是我得到的所有数据都以红色显示

 var cfg = {

  "radius":2,
  "maxOpacity": .8,

  "scaleRadius": false,
  "useLocalExtrema": true,
  latField: 'lat',
  lngField: 'lng',
  valueField: 'value',
  gradient: { 565:"rgb(255,255,204)",1200:"rgb(255,237,160)",1300:"rgb(254,217,118)",1500:"rgb(254,178,76)",1800:"rgb(253,141,60)",2000:"rgb(252,78,42)",2100:"rgb(227,26,28)",2455:"rgb(177,0,38)" }
};
var heatmapLayer = new HeatmapOverlay(cfg);
var map = new L.Map('map', {
  center: new L.LatLng(28.762929,-9.755429),
  zoom: 5,
  maxZoom: 11,
  minZoom: 5,
  layers: [baseLayer, heatmapLayer]
});
heatmapLayer.setData(testData);

layer = heatmapLayer;

You have to use numbers between 0 and 1 for the gardient.您必须使用 0 到 1 之间的数字作为 gardient。

gradient: {
    // enter n keys between 0 and 1 here
    // for gradient color customization
    '.5': 'blue',
    '.8': 'red',
    '.95': 'white'
  },

https://www.patrick-wied.at/static/heatmapjs/example-full-customization.html https://www.patrick-wied.at/static/heatmapjs/example-full-customization.html

https://www.patrick-wied.at/static/heatmapjs/docs.html https://www.patrick-wied.at/static/heatmapjs/docs.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM