<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Kotlin Real Time Sample App in Kotlin Maps SDK Questions</title>
    <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334641#M238</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/719712"&gt;@LeighWoolley&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;The&amp;nbsp;Add custom dynamic entity data source Kotlin sample is planned for the next SDK release, although the implementation should be fairly similar to Java. The API is supported in the Kotlin ArcGIS Maps SDK in version 200.2.0: &lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.realtime/-custom-dynamic-entity-data-source/index.html?query=class%20CustomDynamicEntityDataSource(val%20feedProvider:%20CustomDynamicEntityDataSource.EntityFeedProvider)%20:%20DynamicEntityDataSource" target="_blank" rel="noopener"&gt;API ref&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Configure the custom data source:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a custom data source implementation of a&lt;STRONG&gt; CustomDynamicEntityDataSource&lt;/STRONG&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;val dataSource = CustomDynamicEntityDataSource(
    FlowBuilderProvider(lifecycleScope, observationsFile)
)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Override&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;onLoad&lt;/STRONG&gt;()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to specify the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;DynamicEntityDataSourceInfo&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for a given unique entity ID field and a list of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;objects matching the fields in the data source.&lt;/LI&gt;&lt;LI&gt;Override&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;onConnect&lt;/STRONG&gt;()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to begin processing observations from the custom data source.&lt;/LI&gt;&lt;LI&gt;Loop through the observations and deserialize each observation into a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Geometry&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;object and a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Map&amp;lt;String, Object&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;containing the attributes.&lt;/LI&gt;&lt;LI&gt;Use&lt;STRONG&gt; CustomDynamicEntityDataSource.FeedEvent.NewObservation&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to add each observation to the custom data source.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;private class FlowBuilderProvider(
    scope: CoroutineScope,
    val observationsFile: File
) : CustomDynamicEntityDataSource.EntityFeedProvider {

    private val _feed: Flow&amp;lt;CustomDynamicEntityDataSource.FeedEvent&amp;gt; = flow {
        // set up the bufferedReader on the observationsFile
        // for each line of the file retrieve the geometry, field name and value for the observation
        emit(
            CustomDynamicEntityDataSource.FeedEvent.NewObservation(
                geometry,
                mapOf(trackIdField to trackIdValue)
            )
        )
    }
    override val feed: SharedFlow&amp;lt;CustomDynamicEntityDataSource.FeedEvent&amp;gt; =
        _feed.flowOn(Dispatchers.IO).shareIn(scope, SharingStarted.WhileSubscribed())

    override suspend fun onLoad(): DynamicEntityDataSourceInfo {
        return DynamicEntityDataSourceInfo(
            entityIdFieldName = trackIdField,
            fields = listOf(Field(FieldType.Int64, trackIdField, trackIdField))
        ).apply { spatialReference = SpatialReference.wgs84() }
    }

    override suspend fun onConnect() {}

    override suspend fun onDisconnect() {}

}&lt;/LI-CODE&gt;&lt;P&gt;Configure the map view:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;DynamicEntityLayer&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;using the custom data source implementation.&lt;/LI&gt;&lt;LI&gt;Update values in the layer's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;TrackDisplayProperties&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to customize the layer's appearance.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;val layer = DynamicEntityLayer(dataSource).apply {
    trackDisplayProperties.showPreviousObservations = false
    trackDisplayProperties.showTrackLine = true
    trackDisplayProperties.maximumObservations = 40
}
operationalLayers.add(layer)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Oct 2023 17:24:47 GMT</pubDate>
    <dc:creator>Shubham_Sharma</dc:creator>
    <dc:date>2023-10-03T17:24:47Z</dc:date>
    <item>
      <title>Kotlin Real Time Sample App</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334395#M237</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there an equivalent Kotlin SDK sample app to the Java SDK:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;add_custom_dynamic_entity_data_source&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Oct 2023 01:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334395#M237</guid>
      <dc:creator>LeighWoolley</dc:creator>
      <dc:date>2023-10-03T01:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Kotlin Real Time Sample App</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334641#M238</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/719712"&gt;@LeighWoolley&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;The&amp;nbsp;Add custom dynamic entity data source Kotlin sample is planned for the next SDK release, although the implementation should be fairly similar to Java. The API is supported in the Kotlin ArcGIS Maps SDK in version 200.2.0: &lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.realtime/-custom-dynamic-entity-data-source/index.html?query=class%20CustomDynamicEntityDataSource(val%20feedProvider:%20CustomDynamicEntityDataSource.EntityFeedProvider)%20:%20DynamicEntityDataSource" target="_blank" rel="noopener"&gt;API ref&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Configure the custom data source:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a custom data source implementation of a&lt;STRONG&gt; CustomDynamicEntityDataSource&lt;/STRONG&gt;.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;val dataSource = CustomDynamicEntityDataSource(
    FlowBuilderProvider(lifecycleScope, observationsFile)
)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Override&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;onLoad&lt;/STRONG&gt;()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to specify the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;DynamicEntityDataSourceInfo&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for a given unique entity ID field and a list of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;objects matching the fields in the data source.&lt;/LI&gt;&lt;LI&gt;Override&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;onConnect&lt;/STRONG&gt;()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to begin processing observations from the custom data source.&lt;/LI&gt;&lt;LI&gt;Loop through the observations and deserialize each observation into a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Geometry&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;object and a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Map&amp;lt;String, Object&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;containing the attributes.&lt;/LI&gt;&lt;LI&gt;Use&lt;STRONG&gt; CustomDynamicEntityDataSource.FeedEvent.NewObservation&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to add each observation to the custom data source.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;private class FlowBuilderProvider(
    scope: CoroutineScope,
    val observationsFile: File
) : CustomDynamicEntityDataSource.EntityFeedProvider {

    private val _feed: Flow&amp;lt;CustomDynamicEntityDataSource.FeedEvent&amp;gt; = flow {
        // set up the bufferedReader on the observationsFile
        // for each line of the file retrieve the geometry, field name and value for the observation
        emit(
            CustomDynamicEntityDataSource.FeedEvent.NewObservation(
                geometry,
                mapOf(trackIdField to trackIdValue)
            )
        )
    }
    override val feed: SharedFlow&amp;lt;CustomDynamicEntityDataSource.FeedEvent&amp;gt; =
        _feed.flowOn(Dispatchers.IO).shareIn(scope, SharingStarted.WhileSubscribed())

    override suspend fun onLoad(): DynamicEntityDataSourceInfo {
        return DynamicEntityDataSourceInfo(
            entityIdFieldName = trackIdField,
            fields = listOf(Field(FieldType.Int64, trackIdField, trackIdField))
        ).apply { spatialReference = SpatialReference.wgs84() }
    }

    override suspend fun onConnect() {}

    override suspend fun onDisconnect() {}

}&lt;/LI-CODE&gt;&lt;P&gt;Configure the map view:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;DynamicEntityLayer&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;using the custom data source implementation.&lt;/LI&gt;&lt;LI&gt;Update values in the layer's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;TrackDisplayProperties&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to customize the layer's appearance.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="kotlin"&gt;val layer = DynamicEntityLayer(dataSource).apply {
    trackDisplayProperties.showPreviousObservations = false
    trackDisplayProperties.showTrackLine = true
    trackDisplayProperties.maximumObservations = 40
}
operationalLayers.add(layer)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 17:24:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334641#M238</guid>
      <dc:creator>Shubham_Sharma</dc:creator>
      <dc:date>2023-10-03T17:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Kotlin Real Time Sample App</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334727#M239</link>
      <description>&lt;P&gt;Great, thank you,&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 20:45:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/kotlin-real-time-sample-app/m-p/1334727#M239</guid>
      <dc:creator>LeighWoolley</dc:creator>
      <dc:date>2023-10-03T20:45:09Z</dc:date>
    </item>
  </channel>
</rss>

