Skip to content

Commit 7724260

Browse files
authored
Display alternate symbols at different scales (#441)
1 parent 74be5b8 commit 7724260

File tree

26 files changed

+455
-119
lines changed

26 files changed

+455
-119
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22

33
# ArcGIS Maps SDK for Kotlin version
4-
arcgisMapsKotlinVersion = "300.0.0-4738"
4+
arcgisMapsKotlinVersion = "300.0.0-4757"
55

66
### Android versions
77
androidGradlePlugin = "8.12.1"

samples/add-feature-collection-layer-from-table/src/main/java/com/esri/arcgismaps/sample/addfeaturecollectionlayerfromtable/components/AddFeatureCollectionLayerFromTableViewModel.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,3 @@ class AddFeatureCollectionLayerFromTableViewModel(app: Application) : AndroidVie
213213
return polygonsCollectionTable
214214
}
215215
}
216-
217-
/**
218-
* Define a blue color.
219-
*/
220-
private val Color.Companion.blue: Color
221-
get() {
222-
return fromRgba(r = 0, g = 0, b = 255, a = 255)
223-
}
224-

samples/apply-simple-renderer-to-feature-layer/src/main/java/com/esri/arcgismaps/sample/applysimplerenderertofeaturelayer/components/ApplySimpleRendererToFeatureLayerViewModel.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,3 @@ class ApplySimpleRendererToFeatureLayerViewModel(app: Application) : AndroidView
7777
featureLayer.renderer = renderer
7878
}
7979
}
80-
81-
// Extension property to provide blue color for ArcGISMaps Color class
82-
val Color.Companion.blue: Color
83-
get() = fromRgba(0, 0, 255, 255)

samples/browse-ogc-api-feature-service/src/main/java/com/esri/arcgismaps/sample/browseogcapifeatureservice/components/BrowseOGCAPIFeatureServiceViewModel.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,3 @@ class BrowseOgcApiFeatureServiceViewModel(app: Application) : AndroidViewModel(a
222222
}
223223

224224
}
225-
226-
// Extension property to provide blue color for ArcGISMaps Color class
227-
val Color.Companion.blue: Color
228-
get() = fromRgba(0, 0, 255, 255)

samples/create-and-edit-geometries/src/main/java/com/esri/arcgismaps/sample/createandeditgeometries/components/CreateAndEditGeometriesViewModel.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,4 @@ class CreateAndEditGeometriesViewModel(application: Application) : AndroidViewMo
413413
[-1068004.43,6998409.28],[-1067943.67,6998403.86]]],
414414
"spatialReference":{"latestWkid":3857,"wkid":102100}}"""
415415

416-
/**
417-
* Define a blue color for polylines.
418-
*/
419-
private val Color.Companion.blue: Color
420-
get() {
421-
return fromRgba(0, 0, 255, 255)
422-
}
423-
424416
}

samples/create-convex-hull-around-points/src/main/java/com/esri/arcgismaps/sample/createconvexhullaroundpoints/MainActivity.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,3 @@ class MainActivity : EdgeToEdgeCompatActivity() {
211211
Snackbar.make(mapView, message, Snackbar.LENGTH_SHORT).show()
212212
}
213213
}
214-
215-
/**
216-
* Simple extension property that represents a blue color
217-
*/
218-
private val Color.Companion.blue
219-
get() = fromRgba(0, 0, 255)

samples/cut-geometry/src/main/java/com/esri/arcgismaps/sample/cutgeometry/components/CutGeometryViewModel.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,6 @@ class CutGeometryViewModel(application: Application) : AndroidViewModel(applicat
183183
}
184184
}
185185

186-
/**
187-
* Define a blue color for polygon boundary.
188-
*/
189-
private val Color.Companion.blue: Color
190-
get() {
191-
return fromRgba(
192-
r = 0,
193-
g = 0,
194-
b = 255,
195-
a = 255
196-
)
197-
}
198-
199186
/**
200187
* Create a polygon corresponding to Lake Superior.
201188
*/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Display alternate symbols at different scales
2+
3+
Apply a unique value with alternate symbols at different scales.
4+
5+
![Display alternate symbols at different scales sample](display-alternate-symbols-at-different-scales.png)
6+
7+
## Use case
8+
9+
When a layer is symbolized with unique value symbology, you can specify the visible scale range for each unique value. This is an effective strategy to limit the amount of detailed data at smaller scales without having to make multiple versions of the layer, each with a unique definition query.
10+
11+
Once scale ranges are applied to unique values, you can further refine the appearance of features within those scale ranges by establishing alternate symbols to different parts of the symbol class scale range.
12+
13+
## How to use the sample
14+
15+
Zoom in and out of the map to see alternate symbols at each scale. The symbology changes according to the following scale ranges: 0-5,000, 5,000-10,000, 10,000-20,000. To go back to the initial viewpoint, tap "Reset Viewpoint".
16+
17+
## How it works
18+
19+
1. Create a `FeatureLayer` using the service URL and add it to the map's list of operational layers.
20+
2. Create two alternate symbols (a blue square and a yellow diamond) to be used as alternate symbols. To create an alternate symbol:
21+
1. Create a symbol using `SimpleMarkerSymbol`.
22+
2. Convert the simple marker symbol to an `MultilayerSymbol` using `SimpleMarkerSymbol.toMultilayerSymbol()`.
23+
3. Set the multilayer symbol's `referenceProperties` to the valid scale ranges with the blue square and yellow diamond.
24+
3. Create a third multilayer symbol to be used to create a `UniqueValue` class.
25+
4. Create a unique value using the red triangle from step 3 and the list of alternate symbols from step 2.
26+
5. Create a `UniqueValueRenderer` and add the unique value from step 4 to it.
27+
6. Create a purple diamond simple marker and convert it to a multilayer symbol to be used as the default symbol.
28+
7. Set the unique value renderer's `defaultSymbol` property to the purple diamond from step 6.
29+
8. Set the unique value renderer's `fieldNames` property to "req_type".
30+
9. Apply this unique value renderer to the renderer on feature layer.
31+
32+
## Relevant API
33+
34+
* MultilayerSymbol
35+
* SimpleMarkerSymbol
36+
* SymbolReferenceProperties
37+
* UniqueValue
38+
* UniqueValueRenderer
39+
40+
## About the data
41+
42+
The [San Francisco 311 incidents layer](https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0) in this sample displays point features related to crime incidents such as graffiti and tree damage that have been reported by city residents.
43+
44+
## Tags
45+
46+
alternate symbols, multilayer symbol, scale based rendering, simple marker symbol, symbol reference properties, symbology, unique value, unique value renderer
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"category": "Visualization",
3+
"description": "Apply a unique value with alternate symbols at different scales.",
4+
"formal_name": "DisplayAlternateSymbolsAtDifferentScales",
5+
"ignore": false,
6+
"images": [
7+
"display-alternate-symbols-at-different-scales.png"
8+
],
9+
"keywords": [
10+
"alternate symbols",
11+
"multilayer symbol",
12+
"scale based rendering",
13+
"simple marker symbol",
14+
"symbol reference properties",
15+
"symbology",
16+
"unique value",
17+
"unique value renderer",
18+
"MultilayerSymbol",
19+
"SimpleMarkerSymbol",
20+
"SymbolReferenceProperties",
21+
"UniqueValue",
22+
"UniqueValueRenderer"
23+
],
24+
"language": "kotlin",
25+
"redirect_from": "",
26+
"relevant_apis": [
27+
"MultilayerSymbol",
28+
"SimpleMarkerSymbol",
29+
"SymbolReferenceProperties",
30+
"UniqueValue",
31+
"UniqueValueRenderer"
32+
],
33+
"snippets": [
34+
"src/main/java/com/esri/arcgismaps/sample/displayalternatesymbolsatdifferentscales/components/DisplayAlternateSymbolsAtDifferentScalesViewModel.kt",
35+
"src/main/java/com/esri/arcgismaps/sample/displayalternatesymbolsatdifferentscales/MainActivity.kt",
36+
"src/main/java/com/esri/arcgismaps/sample/displayalternatesymbolsatdifferentscales/screens/DisplayAlternateSymbolsAtDifferentScalesScreen.kt"
37+
],
38+
"title": "Display alternate symbols at different scales"
39+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
alias(libs.plugins.arcgismaps.android.library)
3+
alias(libs.plugins.arcgismaps.android.library.compose)
4+
alias(libs.plugins.arcgismaps.kotlin.sample)
5+
alias(libs.plugins.gradle.secrets)
6+
}
7+
8+
secrets {
9+
// this file doesn't contain secrets, it just provides defaults which can be committed into git.
10+
defaultPropertiesFileName = "secrets.defaults.properties"
11+
}
12+
13+
android {
14+
namespace = "com.esri.arcgismaps.sample.displayalternatesymbolsatdifferentscales"
15+
buildFeatures {
16+
buildConfig = true
17+
}
18+
}
19+
20+
dependencies {
21+
// Only module specific dependencies needed here
22+
}

0 commit comments

Comments
 (0)