Following this post, I created a DataSource from a programmatically generated FeatureLayer.
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:
Solved! Go to Solution.
Got a functional result. Rather than adding DataSource to map, add the FeatureLayer, then add that FeatureLayer to a JimuLayerView, specifying creation during runtime ('true' flag in constructor). Use the DataSource id created earlier in the JimuLayerView constructor as well. Symbology transfers and has datasource functionality:
Hi @jwilner_amica,
When logging my DataSourceManager (dsManager) immediately after the 'addOrRemoveDataOnMap(mapDatas)' line, I get the renderer displayed as such:
So it does seem to be there, but not taking any effect.
I think that because your render is not defined within the DataSourceJson, it is triggering the layer to load with the default renderer. Try moving the layer.renderer = {...} below adding it to the map, so it will first load with the default renderer and then get the unique values.
Unfortunately,
map.current.addOrRemoveDataOnMap(mapDatas)
layer.renderer = {**Omitted renderer**}
did not seem to solve the issue. I also tried putting both lines into a timeout, as you did in the original post, as well as putting the layer.renderer overwrite alone into a timeout, to ensure that the update occurred after the add to map, but neither seemed to have any effect. Is there a way to specify the renderer directly in the DataSourceJson? I couldn't seem to find one, but it is possible I overlooked something. Thank you for your help, you have quite a wealth of knowledge with the ExB developer system!
I am currently working on an update to my add/remove layers widget that will register the layers as datasources. I should have it out later today.
While working on the problem linked to in your original question, I found an issue in that code that adding the datasource causes an additional datasource enabled layer to be added to the map and there were issues with conflicting ids. I think your code could have a similar problem. My widget works by adding the layer (not as a datasource) to the map, using that layer to make a datasource with a different id and then deleting the original layer.
I will look through that, thank you!
@JeffreyThompson2 Got a functional datasource add, may make your widget a bit cleaner than add-remove, but could still use some testing. Hope this can help!
Got a functional result. Rather than adding DataSource to map, add the FeatureLayer, then add that FeatureLayer to a JimuLayerView, specifying creation during runtime ('true' flag in constructor). Use the DataSource id created earlier in the JimuLayerView constructor as well. Symbology transfers and has datasource functionality:
Hi @jwilner_amica,