Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Rallista/maplibre-compose-playground
Composable MapLibre for Android Kotlin.
https://github.com/Rallista/maplibre-compose-playground
android compose jetpack-compose kotlin-android maplibre
Last synced: 4 months ago
JSON representation
Composable MapLibre for Android Kotlin.
- Host: GitHub
- URL: https://github.com/Rallista/maplibre-compose-playground
- Owner: Rallista
- License: mpl-2.0
- Created: 2024-04-07T04:41:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-13T04:36:22.000Z (10 months ago)
- Last Synced: 2024-04-14T11:19:45.532Z (10 months ago)
- Topics: android, compose, jetpack-compose, kotlin-android, maplibre
- Language: Kotlin
- Homepage:
- Size: 1.92 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-maplibre - MapLibre Compose Playground - A Jetpack Compose library that takes inspiration from Ramani, but leans towards API similarity with the SwiftUI DSL and de-emphasizes drawing/editing. (Bindings / Jetpack Compose)
README
# MapLibre Compose Playground
This project is based off of [MPL-2.0 License] and takes a different approach to top level API, emphasizing parity with for .
## Getting Started
This library is published through Maven Central. In your app `build.gradle` add:
```groovy
implementation 'io.github.rallista:maplibre-compose:0.0.16'
```> Note: GitHub package manager releases are deprecated but will remain available.
## Usage
Interact with Maplibre Native from Jetpack Compose using the `MapView`.
```swift
var mapViewCamera = rememberMapViewCamera()MapView(
styleUrl = "https://demotiles.maplibre.org/style.json",
camera = mapViewCamera
)
```
### Local development in an app
Local development in your Android app projects is a bit tricky,
but here's something that mostly works
without thoroughly confusing yourself with Maven Local repos.
(This is definitely a hack, but it works; suggestions welcome.)First, do a local release build.
```shell
./gradlew assembleRelease
```Then, update your `build.gradle` to reference the locally built AAR
(`api` works as well of course, if you had an API dependency):```groovy
implementation files('/path/to/maplibre-compose-playground/compose/build/outputs/aar/compose-release.aar')
```You will also need to manually specify any MapLibre dependencies now.
For example:```groovy
api 'org.maplibre.gl:android-sdk:10.3.1'
api 'org.maplibre.gl:android-plugin-annotation-v9:2.0.2'
```### Setting an API Key for the Light and Dark Mode Demo
Copy or move `api_keys_template.xml` from the root directory to `app/src/main/res/values/api_keys.xml` and add your own API key. The demo uses https://stadiamaps.com as the map style provider, but can easily be adjusted to review with another provider.
### Example Scenes
* [Callback Example](app/src/main/java/com/maplibre/example/examples/CameraExample.kt) - Shows several event callbacks that can be implemented from the `MapView`.
* [Camera Example](app/src/main/java/com/maplibre/example/examples/CameraExample.kt) - Shows the basics of camera control using the `MapViewCamera`.
* [Dark and Light Mode Example](app/src/main/java/com/maplibre/example/examples/DarkAndLightModeExample.kt) - Shows usage of rememberMapStyleUrl which dynamically changes the map style based on if the system theme is dark mode. The styles are injected using a Compose wrapper in MainActivity.kt (similar to how a MaterialTheme is injected).
* [Symbol Example](app/src/main/java/com/maplibre/example/examples/SymbolExample.kt) - Shows the basics of Composable symbol creation.