Good Day
I have a layer with ~790k features which is comprised of 15 800 features over 50 years, 15 800 * 50 = 790k. At any one point I only need to show 1 year or 15 800 features, and the field I need to filter on is called "Year". I'm using a Hosted Feature Layer and my current process is:
1. Grab the Feature Layer by Portal ID
2. Run a query on that layer give me all features
3. Use those features to build the render settings
4. Set the initial definitionExpression to the 2022, so I see the first batch of 15 800 features
5. Add that layer to the map:
this._layers = [];
this._layers.push(new FeatureLayer({
portalItem: {
id: "<feature id>"
},
}))
this.buildRenderSetting().then((render) => {
if (_.isEmpty(this._year)) {
this._year = new Date().getFullYear();
}
this._layers[0].renderer = render;
if (this._year) {
this._layers[0].definitionExpression = 'Year = ' + this._year;
}
this._map.removeAll();
this._layers.forEach((layer) => {
this._map.add(layer);
})
})
This works great, and I get a nice map with the first 15 800 features, the problem is when I change the year!
My code to handle the year change:
if (changes.year.currentValue) {
console.log('Year Changed');
console.log(changes.year.currentValue);
this._view.when(() => {
this._view.map.layers.forEach((layer) => {
layer.definitionExpression = 'Year = ' + this._year;
})
})
})
When that code executes I'm getting a really latent update, that results in several tile errors, and the map locks up for a solid minute or two, before eventually updating. If I'm zoomed in to a small area ~200 features, the update is much faster, on the order of seconds.
I've tried to use both FeatureFilter and FeatureEffect, but those run so slow that it's honestly unusable, and I can replicate the same experience with Effect / Filter on ArcGIS Online with this same layer.
I'm using a UniqueRenderValue for the render setting, looks like:
const uniqueRenderSettings = {
type: 'unique-value',
valueExpression: `When(${_valueExpression})`,
uniqueValueInfos: [{
value: <renderKey>,
label: <renderKey>,
symbol: {
type: <symbol>,
color: <colour>,
size: 12,
width: 3,
outline: {
width: 4,
color: <symbol>
}
}
}]
}
Is there a way to properly handle this case?
Thanks