Select to view content in your preferred language

StreamLayerView issue cloning feature into Feature Layer

311
7
3 weeks ago
AndrewMurdoch1
Frequent Contributor

Good Day

I have a bunch of assets which are MutliLineStrings that are sent to a Stream Layer.  I need to query them using the StreamLayerView and append some of them to a Feature Layer so I can dynamically work with them.  The issue is when I clone the feature from the StreamLayerView, and add it to the Feature Layer, it doesn't show up correctly.  The grey lines are from the StreamLayer, and they are correct.  The red line is the one I cloned from the Layer View, and added to the Feature Layer.

Screenshot From 2025-05-08 12-50-24.png

const query = {
    outFields: ['*'],
    where: '1=1',
    returnGeometry: true
}

this._view.map.layers.forEach((layer: StreamLayer) => {
	if (layer.type === 'stream') {
		this._view.whenLayerView(layer).then((layerView: StreamLayerView) => {
			layerView.queryFeatures(query).then((features) => {
                        const newFeatures = [];
            		features.features.forEach((feature) => {
            	            newFeature.push(feature.clone())
			})
		})
	}
})

this.featureLayer =
    new FeatureLayer(
        this.buildFeatureLayer(
            newFeatures[0].geometry.type,
            fields,
            newFeatures
        )
    )

 

The code above is just a sample, but what would cause the issue I'm experiencing?  Is there a way to prevent it, the StreamLayer is showing the feature correctly, so I'm assuming it's a problem from the StreamLayerView query?  

Thanks

0 Kudos
7 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Would you mind sharing a simple reproducible example? It would help us understand the issue more clearly and troubleshoot it faster.

0 Kudos
AndrewMurdoch1
Frequent Contributor

There's no way to set up a simple Stream Layer example, it would involve setting up a backend, database, frontend, and hooking it altogether, If I give you a SQL file, GO Backend, Angular Frontend, would that work? Can you run each separate part?

Thanks

0 Kudos
UndralBatsukh
Esri Regular Contributor

Can you please post the geometry (json representation) that is in question here? 

0 Kudos
UndralBatsukh
Esri Regular Contributor
0 Kudos
AndrewMurdoch1
Frequent Contributor

Good Evening

It seems to be a problem with the Feature Layer not redrawing the features, if I zoom in to that area above, and force it to query the layerView, the Feature Layer looks fine. I think when the initial query happens, the geometries are messed up, but get refreshed when zooming in.   When those coloured features are added to the Feature Layer the map extent is rather zoomed out, is there a way to force the Feature Layer to redraw included Features?

0 Kudos
UndralBatsukh
Esri Regular Contributor

That should not happen. Repro case would be useful in this case. Which version of the API are you using?

0 Kudos
AndrewMurdoch1
Frequent Contributor

Please excuse the delay in response, I can't provide you with access to that data, I was checking if I could.  The to the issue was to run the following, when the view is stationary:

this.featureLayer.applyEdits({
    addFeatures: <new features>,
    deleteFeatures: <current features>,
}).then(function (editResult) {
    console.log(editResult);
    r(null)
});


Which removes all the current features on the map, and adds them again given the current extent, which causes them to render, resolving the issue.  I guess due to the fully zoomed out extent, the graphics are stored in the Layer View in a rough form, which is why during the query on the Layer View, and then throwing them into the Feature Layer caused the problem I was experiencing.


0 Kudos