View in MAUI WPF WinUI View on GitHub
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Display data from an ArcGIS stream service using a dynamic entity layer.

Image of display dynamic entity layer

Use case

A stream service is a type of service provided by ArcGIS Velocity and GeoEvent Server that allows clients to receive a stream of data observations via a web socket. ArcGIS Maps SDK for .NET allows you to connect to a stream service and manage the information as dynamic entities and display them in a dynamic entity layer. Displaying information from feeds such as a stream service is important in applications like dashboards where users need to visualize and track updates of real-world objects in real-time.

Use

to manage the connection to the stream service and purge options to manage how much data is stored and maintained by the application. The dynamic entity layer will display the latest received observation, and you can set track display properties to determine how to display historical information for each dynamic entity. This includes the number of previous observations to show, whether to display track lines in-between previous observations, and setting renderers.

How to use the sample

Use the controls to connect to or disconnect from the stream service, modify display properties in the dynamic entity layer, and purge all observations from the application.

How it works

  1. Create an
    using a
    .
  2. Set a
    on the stream service to limit the amount of data coming from the server.
  3. Set the
    property of the stream service
    to limit the amount of data managed by the application.
  4. Create a
    using the stream service.
  5. Update values in the layer’s
    to customize the layer’s appearance.
  6. Add the
    to the map.

Relevant API

  • ArcGISStreamService
  • ArcGISStreamServiceFilter
  • ConnectionStatus
  • DynamicEntity
  • DynamicEntityLayer
  • DynamicEntityPurgeOptions
  • TrackDisplayProperties

About the data

This sample uses a stream service that simulates live data coming from snowplows near Sandy, Utah. There are multiple vehicle types and multiple agencies operating the snowplows.

Additional information

More information about dynamic entities can be found in the guide documentation.

Tags

data, dynamic, entity, live, purge, real-time, service, stream, track

Sample Code

AddDynamicEntityLayer.xaml AddDynamicEntityLayer.xaml AddDynamicEntityLayer.xaml.cs
<UserControl x:Class="ArcGIS.WinUI.Samples.AddDynamicEntityLayer.AddDynamicEntityLayer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border x:Name="MainUI" Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock Name="ConnectionStatusLabel" />
<Button x:Name="ConnectionButton"
Margin="5"
Click="ConnectionButton_Click"
IsEnabled="False" />
<CheckBox Margin="5"
Checked="LineVisibilityCheckbox_Checked"
Content="Track lines"
IsChecked="True"
Unchecked="LineVisibilityCheckbox_Checked" />
<CheckBox Margin="5"
Checked="EntityVisibilityCheckbox_Checked"
Content="Previous observations"
IsChecked="True"
Unchecked="EntityVisibilityCheckbox_Checked" />
<TextBlock Grid.Column="0" Text="Previous observations per track:" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding ElementName=EntitiesSlider, Path=Value}" />
<Slider Name="EntitiesSlider"
Grid.Column="1"
VerticalAlignment="Center"
Maximum="16"
Minimum="1"
TickFrequency="1"
ValueChanged="Slider_ValueChanged"
Value="5" />
</Grid>
<Button Margin="5"
Click="PurgeButton_Click"
Content="Purge all observations" />
</StackPanel>
</Border>
</Grid>
</UserControl>