Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
23 lines
1.1 KiB
Markdown
23 lines
1.1 KiB
Markdown
# Distance Expression
|
|
|
|
{{ activity_source_note("DistanceExpressionActivity.kt") }}
|
|
|
|
This example shows how you can modify a style to only show certain features within a certain distance to a point. For this the [distance expression](https://maplibre.org/maplibre-style-spec/expressions/#within) is used.
|
|
|
|
<figure markdown="span">
|
|
 }}){ width="400" }
|
|
{{ openmaptiles_caption() }}
|
|
</figure>
|
|
|
|
First we add a [fill layer](https://maplibre.org/maplibre-style-spec/layers/#fill) and a GeoJSON source.
|
|
|
|
```kotlin
|
|
--8<-- "MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/style/DistanceExpressionActivity.kt:FillLayer"
|
|
```
|
|
|
|
Next, we only show features from symbol layers that are less than a certain distance from the point. All symbol layers whose identifier does not start with `poi` are completely hidden.
|
|
|
|
```kotlin
|
|
--8<-- "MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/style/DistanceExpressionActivity.kt:distanceExpression"
|
|
```
|