Loading...

Getting Started with Android SDK v5

Mappedin SDK for Android helps to deliver the rich indoor mapping experience of a venue, inside Android apps.

The Mappedin SDK for Android is a native interface to the Web SDK. The SDK is a dependency built using Kotlin, and it automatically handles any authentication, network communication, fetching of map data, its display, and basic user interaction, such as panning, tapping, and zooming. The SDK allows a developer to build their own interactions. Additional layers can be rendered on top of the map rendered by the SDK.

Mappedin Android SDK is supported on Android versions 8.0 and above

Concepts

  • After the quick initial setup and configuration, the SDK renders the maps associated with the provided keys, inside an MPIMapView instance.
  • The SDK allows rendering a venue's maps in 3D. The SDK pulls the most up to date data from Mappedin CMS for all points of interest within a venue.
  • The SDK supports drawing navigation paths and providing instructions to and from any point of interest within the venue. Both accessible and non-accessible optimized routes are supported. You can build more functionality on top of this experience, such as searching or switching venues.

Further pieces of this guide give you more details about how to setup the SDK and customize it as per your liking.

Quickstart

Add Permissions

Add the following permissions to the AndroidManifest.xml below <application />.

<uses-permission android:name="android.permission.INTERNET" />
<!--Permissions below are only needed if displaying user location-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

Ensure that hardware acceleration not turned off by setting it to true.

<application
android:hardwareAccelerated="true"
/>

Add Application Dependency to Gradle

Add the Mappedin SDK dependency to the application's build.gradle and sync the changes to download the SDK. The latest version can be found in in Maven.

implementation("com.mappedin.sdk:mappedin:5.0.4")

Refer to the Mappedin Github repository to view the sample app created by Mappedin developers to understand how to embed a map into your app.

Display the Venue

Developers building an app using Jetpack Compose should switch to the Using Jetpack Compose guide. Developers building an app using XML based layouts should continue reading this guide.

Create an MPIMapView

Add an MPIMapView view to activity_main.xml and give it an id mapView:

<com.mappedin.sdk.MPIMapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

In MainActivity.kt, add the following imports:

import com.mappedin.sdk.MPIMapView
import com.mappedin.sdk.listeners.MPIMapViewListener
import com.mappedin.sdk.models.*
import com.mappedin.sdk.web.MPIOptions

Get a handle for the map view in the activity_main layout:

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val mapView = findViewById<MPIMapView>(R.id.mapView)
}

Load the Venue

loadVenue is a MPIMapView function that renders the venue in an app by passing in an options object and an optional showVenueOptions object.

The options object contains a venue, clientId, clientSecret, and optional headers. To get started use the Mappedin Id and Secret that has access to demo venues. To start using your own venues with the SDK you will need to contact a Mappedin representative to get your own unique Id and Secret.

PropertyValue
venuemappedin-demo-mall
clientIdSee Here
clientSecretSee Here

Optionally, pass in showVenueOptions to modify the properties of the map, including backgroundColor, firstMapId, labelAllLocationsOnInit (whether labels appear), backgroundAlpha, on the first load. The following sample code shows an example of how to use it:

// use loadVenue to load venue
mapView.loadVenue(
MPIOptions.Init("5eab30aa91b055001a68e996", "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
"mappedin-demo-mall",
headers = listOf(MPIHeader("testName", "testValue"))),
MPIOptions.ShowVenue(labelAllLocationsOnInit = true, backgroundColor = "#CDCDCD")
) {}

Result

The app should display something that looks like this in the Android Emulator:

Android SDK v5 - onDataLoaded

And zooming in to have a closer look: Android SDK v5 - onDataLoaded zoomed

Was this page helpful?