Installation
Gradle Plugin
Add GitHub Package Registry
Create GitHub token
GitHub package registry requires authentication credentials. These must be created by following the guide here: https://github.com/settings/tokens/new
You will need to enable the following scope on the GitHub token creation form:
Add GitHub Package Registry to project Gradle
If your project uses the legacy buildscript { dependencies }
method to add build script dependencies then add the Github package registry to the top level build.gradle
file as so:
An example can be found here: build.gradle
If your project uses the pluginManagement { repositories }
method to configure plugin resolution then add the Github package registry to the settings.gradle
file as so:
Use environment variables for credential storage
To avoid saving your GitHub credentials directly in your repo you can add them to your environment variables. They can then be accessed like so: === "Groovy" === "Kotlin"Add the MapLayr plugin class path to Gradle
Add the MapLayr plugin class path to Gradle by adding the following dependency to the top level build.gradle
as so:
An example can be found here: build.gradle
Add MapLayr Plugin to Gradle
Add the MapLayr plugin to Gradle in the app module build.gradle
as so:
An example can be found here: app/build.gradle
Use MapLayr Plugin
In the app module build.gradle
configure the plugin.
API Key
The apiKey
is required for any usage of the SDK
An example can be found here: app/build.gradle
Bundle maps at build time
Maps can be downloaded at build time and bundled into the resulting aab
or apk
file, which makes the maps available for immediate use when the user opens the app even if they are offline.
Bundle a single map
To bundle a single map specify the desired map id using the mapId
key as so:
This map id can be retrieved in your code by using BuildConfig.MAPLAYR_MAP_0
if buildConfig
is enabled in your app's gradle file
Bundle multiple maps
Multiple maps can be specified by using the mapIds
key as so:
These map ids can be retrieved in your code by using BuildConfig.MAPLAYR_MAP_0
, BuildConfig.MAPLAYR_MAP_1
, ... , BuildConfig.MAPLAYR_MAP_N
if buildConfig
is enabled in your app's gradle file
Bundle named map(s)
Map id(s) can be provided alongside a friendly name by using the maps
key as so:
These map id(s) can be retrieved in your code by using the friendly name(s); BuildConfig.MAPLAYR_MAP_MY_FIRST_MAP
, BuildConfig.MAPLAYR_MAP_MY_SECOND_MAP
if buildConfig
is enabled in your app's gradle file
Build variants, build types & product flavors
Any of the methodologies above for specifying map ids to be bundled into the app at build time can be nested in the build variants, build types or product flavors namespace to make them specific to that build.
attractionsIo {
variants {
maybeCreate("variant1").apply {
setMapId("{map_id}")
}
maybeCreate("variant2").apply {
setMapId("{map_id}")
}
}
buildTypes {
maybeCreate("buildType1").apply {
setMapId("{map_id}")
}
maybeCreate("buildType2").apply {
setMapId("{map_id}")
}
}
productFlavors {
maybeCreate("productFlavor1").apply {
setMapId("{map_id}")
}
maybeCreate("productFlavor2").apply {
setMapId("{map_id}")
}
}
}
An example can be found here: app/build.gradle
Set cache time
The maps are cached for a default period of 24 hours but this can be modified. For example, a build system could have this set to 0
so that the latest map is downloaded for every build.
An example can be found here: app/build.gradle
MapLayr Implementation
Use the same GitHub token as created above #Create GitHub token
Add GitHub Package Registry to module Gradle
If your project uses the legacy per-module repositories {}
block within the module's build.gradle
file then add the GitHub package registry to the module level build.gradle
as so:
An example can be found here: app/build.gradle
If your project uses the centralised repository approach within settings.gradle
using the dependencyResolutionManagement { repositories }
block then add the GitHub package registry as so:
Add MapLayr implementation to Gradle module dependencies
An example can be found here: app/build.gradle