Я изо всех сил старался, но не смог показать тепловую карту на FeatureLayer с последней версией ArcGIS JavaScript API 4.8. Мой код расположен здесь. Я использовал 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]
});
@BigGerman Вы правы. Я попытался добавить поле field: "heat"
, но оно не работает.
Я задал вопрос сообществу Esri GeoNet, и они ответили на него довольно быстро. Вы можете найти подробные ответы здесь. Вот ответ:
Heatmap requires WebGL, which requires Feature Layer services that are hosted or 10.6.1+. Heatmap with a collection of graphics does not work at the moment.
Они также ответили на вопросы сообщества географической информационной системы StackExchange. Вы можете найти ответ здесь. Ответ:
The HeatmapRenderer only works with WebGL-enabled FeatureLayer, and at version 4.8 one of the limitations for WebGL-support is listed as: Layers created from feature collections or client-side graphics are not supported. https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#webgl-rendering This limitation should hopefully go away at next release (version 4.9).
Я работаю с версией 4.10, и моя тепловая карта не работает. Эта функция все еще не работает для FeatureLayer
с Graphic
как source
, или я делаю что-то не так?
Я заметил одну вещь: вы не определяете целевое поле для HeatMapRenderer (см. пример). Я думаю, вам нужно определить это свойство, то есть
field: "heat"
. Однако изменение этого в скрипке, похоже, не решило проблему, поэтому должно быть что-то еще.