Bundling a Map
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
Map Cache Configuration
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