×
Online Maps Available | Maps SDK for Android | General Magic Online Maps Available — Maps & Navigation SDKs documentation
Skip to content

Online Maps Available

In this guide you will learn how to list the maps available in the online content store and download a map.

Setup

First, get an API key token, see the Getting Started guide.

Download the Maps & Navigation SDK for Android archive file

Download the OnlineMaps project archive file or clone the project with Git

See the Configure Android Example guide.

Run the example

In Android Studio, from the File menu, select Sync Project with Gradle Files

An android device should be connected via USB cable.
Press SHIFT+F10 to compile, install and run the example on the android device.
Android example screenshot

The example gets and displays the list of maps available for download in the online content store, and downloads a map.

How it works

Android example screenshot

You can open the MainActivity.kt file to see how to list the available maps on the server and download a map.

1// Kotlin code
2SdkSettings.onConnected =
3{
4    SdkCall.execute {
5        contentStore.asyncGetStoreContentList(EContentType.RoadMap.value, progressListener)
6    }
7}

Get the list of maps available for download from the online content store server. This launches the request to get the list.

 1// Get the list of maps that was retrieved in the content store.
 2val result = contentStore.getStoreContentList(EContentType.RoadMap.value)
 3if (result != null) models = result.first
 4
 5if (!models.isNullOrEmpty())
 6{
 7  // The map items list is not empty or null.
 8  val item = models[0]
 9  val itemName = item.getName()
10
11  // Define a listener to the progress of the map download action.
12  val downloadProgressListener = ProgressListener.create(
13      onStarted = {
14          progressBar?.visibility = View.VISIBLE
15          Toast.makeText(
16              this@MainActivity,
17              "Started downloading $itemName.",
18              Toast.LENGTH_SHORT
19          ).show()
20      },
21      onCompleted = { _, _ ->
22          progressBar?.visibility = View.GONE
23          Toast.makeText(
24              this@MainActivity,
25              "$itemName was downloaded.",
26              Toast.LENGTH_LONG
27          ).show()
28      },
29      postOnMain = true
30  )
31
32  // Start downloading the first map item.
33  SdkCall.execute {
34      item.asyncDownload(
35          downloadProgressListener,
36          GemSdk.EDataSavePolicy.UseDefault,
37          true
38      )
39  }
40}

This is the callback receiving the result of the list request. If the list of maps from the server is not empty, select the first map (index 0) and download it.

Android Examples

Maps SDK for Android Examples can be downloaded or cloned with Git