-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
demo-app/src/commonMain/composeResources/files/data/* linguist-vendored |
1 change: 1 addition & 0 deletions
1
demo-app/src/commonMain/composeResources/files/data/amtrak_routes.geojson
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...-app/src/commonMain/kotlin/dev/sargunv/maplibrecompose/demoapp/demos/AnimatedLayerDemo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dev.sargunv.maplibrecompose.demoapp.demos | ||
|
||
import androidx.compose.animation.animateColor | ||
import androidx.compose.animation.core.infiniteRepeatable | ||
import androidx.compose.animation.core.keyframes | ||
import androidx.compose.animation.core.rememberInfiniteTransition | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import dev.sargunv.maplibrecompose.compose.MaplibreMap | ||
import dev.sargunv.maplibrecompose.compose.layer.Anchor | ||
import dev.sargunv.maplibrecompose.compose.layer.LineLayer | ||
import dev.sargunv.maplibrecompose.compose.rememberCameraState | ||
import dev.sargunv.maplibrecompose.compose.source.rememberGeoJsonSource | ||
import dev.sargunv.maplibrecompose.core.camera.CameraPosition | ||
import dev.sargunv.maplibrecompose.demoapp.DEFAULT_STYLE | ||
import dev.sargunv.maplibrecompose.demoapp.generated.Res | ||
import io.github.dellisd.spatialk.geojson.Position | ||
import org.jetbrains.compose.resources.ExperimentalResourceApi | ||
|
||
private const val ROUTES_FILE = "files/data/amtrak_routes.geojson" | ||
|
||
private val US = Position(latitude = 46.336, longitude = -96.205) | ||
|
||
@Composable | ||
@OptIn(ExperimentalResourceApi::class) | ||
fun AnimatedLayerDemo() = Column { | ||
MaplibreMap( | ||
modifier = Modifier.weight(1f), | ||
styleUrl = DEFAULT_STYLE, | ||
cameraState = rememberCameraState(firstPosition = CameraPosition(target = US, zoom = 2.0)), | ||
) { | ||
val routeSource = rememberGeoJsonSource(id = "amtrak-routes", dataUrl = Res.getUri(ROUTES_FILE)) | ||
|
||
val infiniteTransition = rememberInfiniteTransition() | ||
val animatedColor by | ||
infiniteTransition.animateColor( | ||
Color.hsl(0f, 1f, 0.5f), | ||
Color.hsl(0f, 1f, 0.5f), | ||
animationSpec = | ||
infiniteRepeatable( | ||
animation = | ||
keyframes { | ||
durationMillis = 10000 | ||
for (i in 1..9) Color.hsl(i * 36f, 1f, 0.5f) at (i * 1000) | ||
} | ||
), | ||
) | ||
|
||
Anchor.Below("waterway_line_label") { | ||
LineLayer( | ||
id = "amtrak-routes", | ||
source = routeSource, | ||
color = const(animatedColor), | ||
width = const(4), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters