Draw track LINES to connect previous observations to show a path that a moving feature traveled in StreamLayer

574
1
Jump to solution
01-07-2024 10:10 PM
ikenna212
New Contributor

Hi,

I'm creating an streamLayer with a custom server. So far I have things working well, but I have not been able to draw a line connecting previous observations. When I set the maximumObservations parameter, I have a group of point moving, what I want is a line showing the path.

There is this guide explaining how to do it on ArcGIS Pro, but I can't seem to replicate the steps with ArcGIS JS SDK. Any hekp is very much appreciated!

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

Since a StreamLayer can only support one geometryType, you won't be able to use a point layer to display lines.  However, you can mimic this by adding a GraphicsLayer, getting the point data from your StreamLayer, creating a line from those points, and adding it to the GraphicsLayer.

The trickiest part of that is getting the point data from the StreamLayer, but even that's not all that bad.  To do this, you'll need to get a reference to its associated StreamLayerView.  The StreamLayerView has a data-received event that fires when new features are received.  It also has a queryFeatures function which you can also use to get the points from your StreamLayer.  Between these, you'd have all you need to create and display the track line(s) in the GraphicsLayer.

View solution in original post

1 Reply
JoelBennett
MVP Regular Contributor

Since a StreamLayer can only support one geometryType, you won't be able to use a point layer to display lines.  However, you can mimic this by adding a GraphicsLayer, getting the point data from your StreamLayer, creating a line from those points, and adding it to the GraphicsLayer.

The trickiest part of that is getting the point data from the StreamLayer, but even that's not all that bad.  To do this, you'll need to get a reference to its associated StreamLayerView.  The StreamLayerView has a data-received event that fires when new features are received.  It also has a queryFeatures function which you can also use to get the points from your StreamLayer.  Between these, you'd have all you need to create and display the track line(s) in the GraphicsLayer.