Skip to content

Commit 24d6391

Browse files
Add dynamic entity layer (#139)
Co-authored-by: Shubham Sharma <[email protected]>
1 parent 7733125 commit 24d6391

26 files changed

+967
-0
lines changed

add-dynamic-entity-layer/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Add dynamic entity layer
2+
3+
Display data from an ArcGIS stream service using a dynamic entity layer.
4+
5+
![Image of add dynamic entity layer](add-dynamic-entity-layer.png)
6+
7+
## Use case
8+
9+
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 Kotlin 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.
10+
11+
Use `ArcGISStreamService` 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.
12+
13+
## How to use the sample
14+
15+
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.
16+
17+
## How it works
18+
19+
1. Create an `ArcGIStreamService` using a `Url`.
20+
2. Set a `DynamicEntityFilter` on the stream service to limit the amount of data coming from the server.
21+
3. Set the `MaximumDuration` property of the stream service `PurgeOptions` to limit the amount of data managed by the application.
22+
4. Create a `DynamicEntityLayer` using the stream service.
23+
5. Update values in the layer's `TrackDisplayProperties` to customize the layer's appearance.
24+
6. Add the `DynamicEntityLayer` to the map.
25+
26+
## Relevant API
27+
28+
* ArcGISStreamService
29+
* DynamicEntity
30+
* DynamicEntityFilter
31+
* DynamicEntityLayer
32+
* DynamicEntityPurgeOptions
33+
* TrackDisplayProperties
34+
35+
## About the data
36+
37+
This sample uses a [stream service](https://realtimegis2016.esri.com:6443/arcgis/rest/services/SandyVehicles/StreamServer) that simulates live data coming from snowplows near Sandy, Utah. There are multiple vehicle types and multiple agencies operating the snowplows.
38+
39+
## Additional information
40+
41+
More information about dynamic entities can be found in the [guide documentation](https://developers.arcgis.com/kotlin/real-time/work-with-dynamic-entities/).
42+
43+
## Tags
44+
45+
data, dynamic, entity, live, purge, real-time, service, stream, track
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"category": "Layers",
3+
"description": "Display data from an ArcGIS stream service using a dynamic entity layer.",
4+
"formal_name": "AddDynamicEntityLayer",
5+
"ignore": false,
6+
"images": [
7+
"add-dynamic-entity-layer.png"
8+
],
9+
"keywords": [
10+
"data",
11+
"dynamic",
12+
"entity",
13+
"live",
14+
"purge",
15+
"real-time",
16+
"service",
17+
"stream",
18+
"track",
19+
"ArcGISStreamService",
20+
"DynamicEntity",
21+
"DynamicEntityFilter",
22+
"DynamicEntityLayer",
23+
"DynamicEntityPurgeOptions",
24+
"TrackDisplayProperties"
25+
],
26+
"language": "kotlin",
27+
"redirect_from": "",
28+
"relevant_apis": [
29+
"ArcGISStreamService",
30+
"DynamicEntity",
31+
"DynamicEntityFilter",
32+
"DynamicEntityLayer",
33+
"DynamicEntityPurgeOptions",
34+
"TrackDisplayProperties"
35+
],
36+
"snippets": [
37+
"src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/MainActivity.kt",
38+
"src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/BottomSheetContent.kt",
39+
"src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/ComposeMapView.kt",
40+
"src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/components/MapViewModel.kt",
41+
"src/main/java/com/esri/arcgismaps/sample/adddynamicentitylayer/screens/MainScreen.kt"
42+
],
43+
"title": "Add dynamic entity layer"
44+
}
Loading

add-dynamic-entity-layer/build.gradle

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'org.jetbrains.kotlin.android'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
7+
defaultConfig {
8+
applicationId "com.esri.arcgismaps.sample.adddynamicentitylayer"
9+
minSdkVersion rootProject.ext.minSdkVersion
10+
targetSdkVersion rootProject.ext.targetSdkVersion
11+
versionCode rootProject.ext.versionCode
12+
versionName rootProject.ext.versionName
13+
buildConfigField("String", "API_KEY", API_KEY)
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
23+
buildFeatures {
24+
compose = true
25+
buildConfig = true
26+
}
27+
composeOptions {
28+
kotlinCompilerExtensionVersion = "$kotlinCompilerExt"
29+
}
30+
31+
namespace 'com.esri.arcgismaps.sample.adddynamicentitylayer'
32+
}
33+
34+
dependencies {
35+
// lib dependencies from rootProject build.gradle
36+
implementation "androidx.core:core-ktx:$ktxAndroidCore"
37+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktxLifecycle"
38+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$ktxLifecycle"
39+
implementation "androidx.activity:activity-compose:$composeActivityVersion"
40+
// Jetpack Compose Bill of Materials
41+
implementation platform("androidx.compose:compose-bom:$composeBOM")
42+
// Jetpack Compose dependencies
43+
implementation "androidx.compose.ui:ui"
44+
implementation "androidx.compose.material3:material3"
45+
implementation "androidx.compose.ui:ui-tooling"
46+
implementation "androidx.compose.ui:ui-tooling-preview"
47+
implementation project(path: ':samples-lib')
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:exported="true"
15+
android:name=".MainActivity">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* Copyright 2023 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
package com.esri.arcgismaps.sample.adddynamicentitylayer
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.material3.MaterialTheme
23+
import androidx.compose.material3.Surface
24+
import androidx.compose.runtime.Composable
25+
import com.arcgismaps.ApiKey
26+
import com.arcgismaps.ArcGISEnvironment
27+
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
28+
import com.esri.arcgismaps.sample.adddynamicentitylayer.screens.MainScreen
29+
30+
class MainActivity : ComponentActivity() {
31+
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
// authentication with an API key or named user is
35+
// required to access basemaps and other location services
36+
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY)
37+
setContent {
38+
SampleAppTheme {
39+
AddDynamicEntityLayerApp()
40+
}
41+
}
42+
}
43+
44+
@Composable
45+
private fun AddDynamicEntityLayerApp() {
46+
Surface(
47+
color = MaterialTheme.colorScheme.background
48+
) {
49+
MainScreen(
50+
sampleName = getString(R.string.app_name),
51+
application = application
52+
)
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)