arcgis for javascript(4.12)渲染热力图

如何生成一个热力图,arcgis for js4.x提供了热力图的渲染方式

1,指定一下热力图的渲染方式,在esri/renderers/HeatmapRenderer模块可以找到热力图配置参数

   let rendererT = {

                        type: "heatmap",

                        colorStops: [

                            { color: "rgba(63, 40, 102, 0)", ratio: 0 },

                            { color: "#00AFFF", ratio: 0.1 },

                            { color: "#14B441", ratio: 0.3 },

                            { color: "#FFFA00", ratio: 0.7 },

                            { color: "#FF4600", ratio: 1 }

                        ],

                        maxPixelIntensity: 100,

                        minPixelIntensity: 0

                    };

2,创建feature数组,添加faetrue对象,热力图显示的是点的密集程度,所以我们要创建很多point,然后添加到一个数组中

let features=[];

 features.push({

                            geometry: {

                                type: "point",

                                x: x,//经度

                                y: y,//纬度

                                spatialReference: spatialReference,//坐标系

                            },

                            attributes: {

                                ObjectID: i,

                                crime_count: 10

                            }

                        })

3,创建一个FeatrueLayer,将渲染对象rendererT赋给renderer属性

    let featureLayer = new FeatureLayer({

                        geometryType: "point",

                        source: features,

                        title: "热力图",

                        fields: [{ name: "ObjectID", alias: "ObjectID", type: "oid" }, { name: "crime_count", alias: "crime_count", type: "integer" }],

                        objectIdField: "ObjectID",

                        renderer: rendererT,

                    });

map.add(featureLayer)

4,效果如下



你可能感兴趣的:(arcgis for javascript(4.12)渲染热力图)