我尽了最大努力,但没有成功通过最新的ArcGIS JavaScript API 4.8在FeatureLayer上显示热图。我的代码位于here。 我使用HeatMapRenderer将地图上的点渲染为热图。但是不知何故它根本不起作用。我想我缺少一些可以轻松解决的问题。
放入我认为应该修复的JavaScript代码:
const renderer = {
type: "heatmap",
colorStops: [{
color: "rgba(63, 40, 102, 0)",
ratio: 0
},
{
color: "#472b77",
ratio: 0.083
},
{
color: "#4e2d87",
ratio: 0.166
},
{
color: "#563098",
ratio: 0.249
},
{
color: "#5d32a8",
ratio: 0.332
},
{
color: "#6735be",
ratio: 0.415
},
{
color: "#7139d4",
ratio: 0.498
},
{
color: "#7b3ce9",
ratio: 0.581
},
{
color: "#853fff",
ratio: 0.664
},
{
color: "#a46fbf",
ratio: 0.747
},
{
color: "#c29f80",
ratio: 0.830
},
{
color: "#e0cf40",
ratio: 0.913
},
{
color: "#ffff00",
ratio: 1
}
],
maxPixelIntensity: 10,
minPixelIntensity: 0,
blurRadius: 8.764705882352942
};
var point = {
type: "point",
longitude: -81.4230821,
latitude: 28.3103877,
};
var markerSymbol = {
type: "simple-marker",
color: [226, 119, 40]
};
var pointGraphic = new Graphic({
geometry: point,
symbol: markerSymbol
});
let graphics = getGraphics(Graphic);
graphics.push(pointGraphic);
const layer = new FeatureLayer({
title: "Magnitude 2.5+ earthquakes from the last week",
copyright: "USGS Earthquakes",
source: graphics,
popupTemplate: template,
attributionVisible: true,
fields: [{
name: "OBJECTID",
alias: "OBJECTID",
type: "oid"
},
{
name: "id",
alias: "id",
type: "integer"
}, {
name: "agencyId",
alias: "agencyId",
type: "integer"
},
{
name: "heat",
alias: "heat",
type: "number"
}, {
name: "latitude",
alias: "latitude",
type: "number"
}, {
name: "longitude",
alias: "longitude",
type: "number"
}
],
objectIdField: "OBJECTID",
outFields: ["OBJECTID", "heat", "id", "longitude", "latitude", "agencyId"],
geometryType: "point",
opacity: 1,
spatialReference: {
wkid: 4326
},
renderer: renderer
});
const map = new Map({
basemap: "gray",
layers: [layer]
});
答案 0 :(得分:0)
我向Esri GeoNet社区提出了一个问题,他们很快就回答了。您可以找到详细的答案here。 下面是答案:
Heatmap需要WebGL,而WebGL需要托管的功能层服务或10.6.1+。带有图形集合的热图目前不起作用。
他们还回答了StackExchange地理信息系统社区。您可以找到答案here。答案是:
HeatmapRenderer仅与启用WebGL的FeatureLayer一起使用,并且在4.8版中,WebGL支持的限制之一列出为: 不支持从要素集合或客户端图形创建的图层。 https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#webgl-rendering 希望此限制在下一发行版(版本4.9)中消失。