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

Create a custom dynamic entity data source and display it using a dynamic entity layer.

Image of add custom dynamic entity data source

Use case

Developers can create a custom

to be able to visualize data from a variety of different feeds as dynamic entities using a
. An example of this is in a mobile situational awareness app, where a custom
can be used to connect to peer-to-peer feeds in order to visualize real-time location tracks from teammates in the field.

How to use the sample

Run the sample to view the map and the dynamic entity layer displaying the latest observation from the custom data source. Tap on a dynamic entity to view its attributes in a callout.

How it works

Configure the custom data source:

  1. Create a custom data source implementation of a
    .
  2. Override
    to specify the
    for a given unique entity ID field and a list of
    objects matching the fields in the data source.
  3. Override
    to begin processing observations from the custom data source.
  4. Loop through the observations and deserialize each observation into a
    object and a
    containing the attributes.
  5. Use
    to add each observation to the custom data source.

Configure the map view:

  1. Create a
    using the custom data source implementation.
  2. Update values in the layer’s
    to customize the layer’s appearance.
  3. Set up the layer’s
    to display labels for each dynamic entity.
  4. Configure a
    event handler on the
    to select a dynamic entity and display the entity’s attributes in a callout.

Relevant API

  • DynamicEntity
  • DynamicEntityDataSource
  • DynamicEntityLayer
  • LabelDefinition
  • TrackDisplayProperties

About the data

This sample uses a .json file containing observations of marine vessels in the Pacific North West hosted on ArcGIS Online.

Additional information

In this sample, we iterate through features in a GeoJSON file to mimic messages coming from a real-time feed. You can create a custom dyamic entity data source to process any data that contains observations which can be translated into

objects with associated
attributes.

Tags

data, dynamic, entity, label, labeling, live, real-time, stream, track

Sample Code

AddCustomDynamicEntityDataSource.xaml AddCustomDynamicEntityDataSource.xaml AddCustomDynamicEntityDataSource.xaml.cs SimulatedDataSource.cs
<UserControl x:Class="ArcGIS.WinUI.Samples.AddCustomDynamicEntityDataSource.AddCustomDynamicEntityDataSource"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="using:Esri.ArcGISRuntime"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" GeoViewTapped="GeoViewTapped" />
</Grid>
</UserControl>