arcgis api for js入门开发系列九热力图效果

上一篇实现了demo的聚合效果,本篇新增热力图效果,截图如下:

热力图效果实现的思路如下:

1.map.js初始化函数调用聚合效果的js接口,map.heatmap.js实现聚合核心效果的js文件

//加载热力图
DCI.heatmap.Init(map);

2.map.heatmap.js实现热力图核心思路:

调用地图FeatureServer服务,构造Featurelayer来渲染

var serviceURL = "http://localhost:6080/arcgis/rest/services/dlsde/FeatureServer/0";
var heatmapFeatureLayerOptions = {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["NAME", "KIND"]
//infoTemplate: infoTemplate
};
var heatmapFeatureLayer = new esri.layers.FeatureLayer(serviceURL, heatmapFeatureLayerOptions);
heatmapFeatureLayer.id = "heatmap";
var heatmapRenderer = new esri.renderers.HeatmapRenderer({
field: "KIND",
colors: ["rgba(0, 0, 255, 0)", "rgb(0, 0, 255)", "rgb(255, 0, 255)", "rgb(255, 0, 0)"],
blurRadius: 12,
maxPixelIntensity: 250,
minPixelIntensity: 10
});
//监听check点击事件
$("[name = heatmapFeatureLayer]:checkbox").bind("click", function () {
if ($(this).attr("checked")) {
if (DCI.heatmap.map.getLayer("heatmap")) {
DCI.heatmap.map.getLayer("heatmap").show();
} else {
heatmapFeatureLayer.setRenderer(heatmapRenderer);
DCI.heatmap.map.addLayer(heatmapFeatureLayer);
}
}
else {
if (DCI.heatmap.map.getLayer("heatmap"))
DCI.heatmap.map.getLayer("heatmap").hide();
}
})

 

作者: GIS之家

GIS之家微信号:gishome;GIS之家拥有自己的GIS开发团队,均是高校GIS研究生,具备丰富的webgis开发项目工作经验,专注以及热爱研究webgis技术的团队

发表评论

电子邮件地址不会被公开。