Skip to content

Commit 5321223

Browse files
authored
Merge pull request #19 from ArcGIS/sample/display-feature-layers
New sample: Add feature layers
2 parents 6b9d05d + 299a2d5 commit 5321223

File tree

33 files changed

+875
-75
lines changed

33 files changed

+875
-75
lines changed

add-feature-layers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

add-feature-layers/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Add feature layers
2+
3+
Add feature layers from various data sources.
4+
5+
![Add feature layers](add-feature-layers.png)
6+
7+
## Use case
8+
9+
Feature layers, like all layers, are visual representations of data and are used on a map or scene. In the case of feature layers, the underlying data is held in a feature table or feature service.
10+
11+
Feature services are useful for sharing vector GIS data with clients so that individual features can be queried, displayed, and edited. There are various online and offline methods to load feature services.
12+
13+
## How to use the sample
14+
15+
Tap the button on the bottom menu to add feature layers, from different sources, to the map. Pan and zoom the map to view the feature layers.
16+
17+
## How it works
18+
19+
1. Set the basemap with a `BasemapStyle`.
20+
2. Load a feature layer with a URL.
21+
i. Create a `ServiceFeatureTable` from a URL.
22+
ii. Create a `FeatureLayer` with the feature table.
23+
3. Load a feature layer with a portal item.
24+
i. Create a `PortalItem` with the portal and item ID.
25+
ii. Create a `FeatureLayer` with the portal item and with or without the layer ID.
26+
4. Load a feature layer with a geodatabase.
27+
i. Instantiate and load a `Geodatabase` using the file name.
28+
ii. Get the feature table from the geodatabase with the feature table's name.
29+
iii. Create a `FeatureLayer` from the feature table.
30+
5. Load a feature layer with a geopackage.
31+
i. Instantiate and load a geopackage using its file name.
32+
ii. Get the first `GeoPackageFeatureTable` from the `GeoPackage.geoPackageFeatureTables` array.
33+
iii. Create a `FeatureLayer` from the feature table.
34+
6. Load a feature layer with a shapefile.
35+
i. Create a `ShapefileFeatureTable` using the shapefile path.
36+
ii. Create a `FeatureLayer` from the feature table and load it.
37+
7. Add the feature layer to the map's `OperationalLayers`.
38+
39+
## Relevant API
40+
41+
* FeatureLayer
42+
* Geodatabase
43+
* GeoPackageFeatureTable
44+
* PortalItem
45+
* ServiceFeatureTable
46+
* ShapefileFeatureTable
47+
48+
## About the data
49+
50+
This sample uses the [Naperville damage assessment service](https://sampleserver7.arcgisonline.com/server/rest/services/DamageAssessment/FeatureServer/0), [Trees of Portland portal item](https://www.arcgis.com/home/item.html?id=1759fd3e8a324358a0c58d9a687a8578), [Los Angeles Trailheads geodatabase](https://www.arcgis.com/home/item.html?id=2b0f9e17105847809dfeb04e3cad69e0), [Aurora, Colorado GeoPackage](https://www.arcgis.com/home/item.html?id=68ec42517cdd439e81b036210483e8e7), and [Scottish Wildlife Trust Reserves Shapefile](https://www.arcgis.com/home/item.html?id=15a7cbd3af1e47cfa5d2c6b93dc44fc2).
51+
52+
The Scottish Wildlife Trust shapefile data is provided from Scottish Wildlife Trust under [CC-BY licence](https://creativecommons.org/licenses/by/4.0/). Data Copyright Scottish Wildlife Trust (2022).
53+
54+
## Tags
55+
56+
feature, geodatabase, geopackage, layers, service, shapefile, table
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"category": "Layers",
3+
"description": "Add feature layers from various data sources.",
4+
"formal_name": "AddFeatureLayers",
5+
"ignore": false,
6+
"images": [
7+
"add-feature-layers.png"
8+
],
9+
"keywords": [
10+
"feature",
11+
"geodatabase",
12+
"geopackage",
13+
"layers",
14+
"service",
15+
"shapefile",
16+
"table",
17+
"FeatureLayer",
18+
"GeoPackageFeatureTable",
19+
"Geodatabase",
20+
"PortalItem",
21+
"ServiceFeatureTable",
22+
"ShapefileFeatureTable"
23+
],
24+
"language": "kotlin",
25+
"redirect_from": [
26+
"/android/latest/sample-code/feature-layer-feature-service.htm",
27+
"/android/latest/sample-code/feature-layer-geodatabase.htm",
28+
"/android/latest/sample-code/feature-layer-geopackage.htm",
29+
"/android/latest/sample-code/feature-layer-shapefile.htm"
30+
],
31+
"relevant_apis": [
32+
"FeatureLayer",
33+
"GeoPackageFeatureTable",
34+
"Geodatabase",
35+
"PortalItem",
36+
"ServiceFeatureTable",
37+
"ShapefileFeatureTable"
38+
],
39+
"snippets": [
40+
"src/main/java/com/esri/arcgisruntime/sample/addfeaturelayers/DownloadActivity.kt",
41+
"src/main/java/com/esri/arcgisruntime/sample/addfeaturelayers/MainActivity.kt"
42+
],
43+
"title": "Add feature layers"
44+
}
211 KB
Loading

add-feature-layers/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
7+
defaultConfig {
8+
applicationId "com.esri.arcgisruntime.sample.addfeaturelayers"
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+
dataBinding true
25+
}
26+
}
27+
28+
dependencies {
29+
// lib dependencies from rootProject build.gradle
30+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
31+
implementation "com.google.android.material:material:$materialVersion"
32+
implementation "androidx.appcompat:appcompat:$appcompatVersion"
33+
implementation project(path: ':samples-lib')
34+
}
Lines changed: 21 additions & 0 deletions
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
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.esri.arcgisruntime.sample.addfeaturelayers">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity
15+
android:name=".DownloadActivity"
16+
android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity
24+
android:name=".MainActivity"
25+
android:exported="true"
26+
android:label="@string/app_name">
27+
<intent-filter>
28+
<action android:name="android.intent.action.MAIN" />
29+
</intent-filter>
30+
</activity>
31+
</application>
32+
33+
</manifest>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.esri.arcgisruntime.sample.addfeaturelayers
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import com.esri.arcgisruntime.sample.sampleslib.DownloaderActivity
6+
7+
class DownloadActivity : DownloaderActivity() {
8+
override fun onCreate(savedInstanceState: Bundle?) {
9+
super.onCreate(savedInstanceState)
10+
downloadAndStartSample(
11+
Intent(this, MainActivity::class.java),
12+
// get the download path of the sample
13+
getExternalFilesDir(null)?.path.toString(),
14+
listOf(
15+
// ArcGIS Portal item containing the .mmpk mobile map package
16+
"https://www.arcgis.com/home/item.html?id=2b0f9e17105847809dfeb04e3cad69e0",
17+
// ArcGIS Portal item containing shapefiles of Scottish Wildlife Trust reserve boundaries
18+
"https://www.arcgis.com/home/item.html?id=15a7cbd3af1e47cfa5d2c6b93dc44fc2",
19+
// GeoPackage AuroraCO.gpkg with datasets that cover Aurora Colorado
20+
"https://www.arcgis.com/home/item.html?id=68ec42517cdd439e81b036210483e8e7"
21+
)
22+
)
23+
}
24+
}

0 commit comments

Comments
 (0)