manuelnas / CesiumHeatmap

A library to add heatmaps (using heatmap.js) to the Cesium framework.
MIT License
153 stars 110 forks source link

热力图的效果不对 #15

Open 1287642889 opened 4 years ago

1287642889 commented 4 years ago

我使用CesiumHeatmap.js,出现热力图了。但是宽度明显不对,请教一下大神!

let valueMin = 0;
            let valueMax = 100;
            let bounds = {
                west: 90,
                east: 110,
                south: 25,
                north: 50
            };
            window.viewer.camera.setView({
                destination : Cesium.Rectangle.fromDegrees(bounds.west, bounds.south, bounds.east, bounds.north)
            });
            let data = this.getRandomData(1000, bounds, 0, 100);
            let heatMap = CesiumHeatmap.create(
                window.viewer, // your cesium viewer
                bounds, // bounds for heatmap layer
                {
                    // xField: 'x',
                    // yField: 'y',
                    // valueField: 'value',
                    radius: 50,
                    // maxOpacity: 1,
                    // minOpacity: 1,
                    gradient: {
                        '0.9': '#ffffff',
                        '0.7': '#ffff00',
                        '0.5': '#00ff00',
                        '0.2': '#0000ff'
                    }
                }
            );
            heatMap.setWGS84Data(valueMin, valueMax, data);
getRandomData(len, bounds, valueMin, valueMax){
                let lngDist = bounds.east - bounds.west;
                let latDist = bounds.north - bounds.south;
                let valueDist = valueMax - valueMin;
                let data = [];
                for(let i=0; i<len; i++){
                    let lng = bounds.east + Math.random() * lngDist;
                    let lat = bounds.south + Math.random() * latDist;
                    let value = valueMin + Math.random() * valueDist;
                    data.push({
                        x: lng,
                        y: lat,
                        value: value
                    });
                }
                return data;
            }
Kedaxiang commented 3 years ago

想问一下你在用热力图的时候会有这个报错吗TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

TongBig commented 3 years ago

@Kedaxiang 我遇到了,还没解决

Julycc41 commented 3 years ago

大神们我也是一直报这个错getComputedStyle 有解决吗

lfkls-23 commented 2 years ago

let lng = bounds.east + Math.random() * lngDist; 应该是bounds.west