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.
When I use jimuMapView.addLayerToMap(dsId, customLayerId) inside a loop, the DataAction ("Add to Table") works only for the last item in the array. If I add a single layer, the data action works perfectly. I've noticed this behavior in both Experience Builder versions 1.14 and 1.15.
However, when using addOrRemoveDataOnMap, I don't encounter this issue, but the layer ordering doesn't follow the intended sequence. In contrast, with addLayerToMap(), I can use await since it returns a promise.
Any help?
@MohammedHilal_K Can you try calling jimuMapView.addLayerToMap() serially to solve this problem? Similar to the following code
async function addMultipleLayersToMapOneByOne(items) {
for (const item of items) {
const { dataSourceId, targetLayerId } = item;
await jimuMapView.addLayerToMap(dataSourceId, targetLayerId);
}
}
@QunSun @jwilner_amica
still Not working. Also in targetLayerId, what Id it actually required? I'm using 'Wolrd Hillshade' as basemap with no predefined layers.
Also below code works for me for MapImageLayer and FeatureLayer. but what about FeatureService? how can we pass the FeatureService to createJimuLayerView?
targetLayerId is a custom ID you want to set to the layer, as long as you ensure that the ID does not conflict with other layer IDs.
The data action (add to table) is available only for the data sources supporting the query. Layer.fromArcGISServerUrl(featureServiceUrl) will return a Maps SDK group layer, that doesn't support query. The workaround is adding the layers/tables under the feature service individually.