diff --git a/docs/mdbook/src/SUMMARY.md b/docs/mdbook/src/SUMMARY.md index 0123a2b87..9ec063dfe 100644 --- a/docs/mdbook/src/SUMMARY.md +++ b/docs/mdbook/src/SUMMARY.md @@ -8,4 +8,7 @@ - [Expressions](design/expressions.md) - [Architectural Problems and Recommendations](design/archictural-problems-and-recommendations.md) - [Android Map Rendering Data Flow](design/android-map-rendering-data-flow.md) - - [Geometry Tile Worker](design/geometry-tile-worker.md) \ No newline at end of file + - [Geometry Tile Worker](design/geometry-tile-worker.md) + +- [MapLibre GL Native for Android](./android/README.md) + - [Quickstart](./android/getting-started-guide.md) \ No newline at end of file diff --git a/docs/mdbook/src/android/README.md b/docs/mdbook/src/android/README.md new file mode 100644 index 000000000..2306e73d7 --- /dev/null +++ b/docs/mdbook/src/android/README.md @@ -0,0 +1,3 @@ +# MapLibre GL Native for Android + +MapLibre GL Native for Android is a library for embedding interactive map views with scalable, customizable vector maps onto Android devices. \ No newline at end of file diff --git a/docs/mdbook/src/android/getting-started-guide.md b/docs/mdbook/src/android/getting-started-guide.md new file mode 100644 index 000000000..785d5dbb6 --- /dev/null +++ b/docs/mdbook/src/android/getting-started-guide.md @@ -0,0 +1,113 @@ +# Quickstart + +1. Add bintray Maven repositories to your project-level Gradle file (usually `//build.gradle`). + + ```gradle + allprojects { + repositories { + ... + mavenCentral() + } + } + ``` + +2. Add the library as a dependency into your module Gradle file (usually `//build.gradle`). Replace `` with the latest MapLibre GL Native version (e.g.: `org.maplibre.gl:android-sdk:10.0.2`). Visit [https://mvnrepository.com/artifact/org.maplibre.gl/android-sdk](https://mvnrepository.com/artifact/org.maplibre.gl/android-sdk) to view the version history of MapLibre GL Native for android. + + ```gradle + dependencies { + ... + implementation 'org.maplibre.gl:android-sdk:' + ... + } + ``` + +3. Sync your Android project with Gradle files. + +4. Add a `MapView` to your layout XML file (usually `//src/main/res/layout/activity_main.xml`). + + ```xml + ... + + ... + ``` + +5. Initialize the `MapView` in your `MainActivity` file by following the example below: + + ```kotlin + import androidx.appcompat.app.AppCompatActivity + import android.os.Bundle + import android.view.LayoutInflater + import com.mapbox.mapboxsdk.Mapbox + import com.mapbox.mapboxsdk.camera.CameraPosition + import com.mapbox.mapboxsdk.geometry.LatLng + import com.mapbox.mapboxsdk.maps.MapView + + class MainActivity : AppCompatActivity() { + + // Declare a variable for MapView + private lateinit var mapView: MapView + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Init MapLibre + Mapbox.getInstance(this) + + // Init layout view + val inflater = LayoutInflater.from(this) + val rootView = inflater.inflate(R.layout.activity_main, null) + setContentView(rootView) + + // Init the MapView + mapView = rootView.findViewById(R.id.mapView) + mapView.getMapAsync { map -> + map.setStyle("https://demotiles.maplibre.org/style.json") + map.cameraPosition = CameraPosition.Builder().target(LatLng(0.0,0.0)).zoom(1.0).build() + } + } + + override fun onStart() { + super.onStart() + mapView.onStart() + } + + override fun onResume() { + super.onResume() + mapView.onResume() + } + + override fun onPause() { + super.onPause() + mapView.onPause() + } + + override fun onStop() { + super.onStop() + mapView.onStop() + } + + override fun onLowMemory() { + super.onLowMemory() + mapView.onLowMemory() + } + + override fun onDestroy() { + super.onDestroy() + mapView.onDestroy() + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + mapView.onSaveInstanceState(outState) + } + } + ``` + +6. Build and run the app. If you run the app successfully, a map will be displayed as seen in the screenshot below. +
+Screenshot with the map in demotile style +
diff --git a/platform/android/MapboxGLAndroidSDK/README.md b/platform/android/MapboxGLAndroidSDK/README.md new file mode 100644 index 000000000..8312514f5 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/README.md @@ -0,0 +1,5 @@ +# Module MapLibre GL Native for Android + +This is the MapLibre GL Native API for Android doccumentation. + +Visit [https://maplibre.org/maplibre-gl-native/docs/book/android/getting-started-guide.html](https://maplibre.org/maplibre-gl-native/docs/book/android/getting-started-guide.html) to view the Getting Started Guide for MapLibre GL Native for Android. \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index aecd63cb0..6ab7fcc59 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.dokka.gradle.DokkaTask + plugins { id 'org.jmailen.kotlinter' id 'org.jetbrains.dokka' version '1.7.20' @@ -32,6 +34,17 @@ dependencies { androidTestImplementation dependenciesList.testRules } +tasks.withType(DokkaTask.class) { + moduleName.set("MapLibre GL Native for Android") + + dokkaSourceSets { + + configureEach { + includes.from("README.md") + } + } +} + android { compileSdkVersion androidVersions.compileSdkVersion buildToolsVersion androidSdkVersions.buildToolsVersion diff --git a/platform/android/README.md b/platform/android/README.md index 983a4c5f5..3b5d96a9b 100644 --- a/platform/android/README.md +++ b/platform/android/README.md @@ -6,28 +6,7 @@ MapLibre GL Native for Android is a library for embedding interactive map views ## Getting Started -1. Add bintray Maven repositories to your `build.gradle` at project level so that you can access MapLibre packages for Android: - - ```gradle - allprojects { - repositories { - ... - mavenCentral() - } - } - ``` - -2. Add the library as a dependency into your module build.gradle - - ```gradle - dependencies { - ... - implementation 'org.maplibre.gl:android-sdk:' - ... - } - ``` - -3. Sync Gradle and rebuild your app. +Visit [https://maplibre.org/maplibre-gl-native/docs/book/android/getting-started-guide.html](https://maplibre.org/maplibre-gl-native/docs/book/android/getting-started-guide.html) to view the Getting Started Guide for MapLibre GL Native for Android. ## Documentation