Following this post, I created a DataSource from a programmatically generated FeatureLayer.
https://community.esri.com/t5/arcgis-experience-builder-questions/making-runtime-featurelayers-register-as/m-p/1473175#M12641
However, when that DataSource is added to map, it loses its renderer that was defined before. The renderer being used displays some color never used in my UniqueValueRenderer. The code is as follows:
let layer = new FeatureLayer({
source: featureset, // autocast as a Collection of new Graphic()
objectIdField: "OBJECTID",
geometryType: "polygon",
popupTemplate: template,
fields: swath.value.fields,
title: 'Hail Swath ' + dt,
opacity: 0.8
})
layer.renderer = {
type: "unique-value", // autocasts as new UniqueValueRenderer()
field: "diameter_in_label",
defaultSymbol: {
type: "simple-fill",
outline: line,
color: [209, 0, 152, 1.0]
},
uniqueValueInfos: [{
value: '0.75"',
symbol: {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [255, 255, 190, 1.0],
outline: line
}
}, ... ** Omitted long renderer **
}]
}
const data: DataSourceJson = {
id: 'Hail Swath ' + dt,
layerId: layer.id,
type: DataSourceTypes.FeatureLayer,
label: layer.title,
}
const dataJson = Immutable(data)
const dataSourceOptions = {
id: 'Hail Swath ' + dt,
layer: layer,
dataSourceJson: dataJson,
}
dsManager.current.createDataSource(dataSourceOptions).then((source) => {
const sourceId = source.id
const addMapData = {
jimuMapViewId: map.current.id,
dataSourceId: sourceId,
dataChangeType: DataChangeType.Create,
dataChangeStatus: DataChangeStatus.Fulfilled
}
let mapDatas = { sourceId: addMapData }
map.current.addOrRemoveDataOnMap(mapDatas)
console.error('Error creating DataSource:', error);
});
Any help would be appreciated, thank you!