Mappedin Logo


Mappedin Documentation

Android SDK: Quickstart

Android SDK: Quickstart

Add Permissions

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

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

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


Add Application Dependency to Gradle

Add the Mappedin SDK dependency to your build.gradle. You can find the latest version in Maven.

implementation 'com.mappedin.sdk:mappedin:4.0.17'

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

Display the Venue

Create an MPIMapView

Next you will need to add an MPIMapView view in your activity_main.xml and give it an id mapView:

app:layout_constraintTop_toTopOf="parent" />

In your 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

Then set your content view to the activity_main layout:

override fun onCreate(savedInstanceState: Bundle?) {
Load the Venue

loadVenue is a MPIMapView function that allows you to render the venue in your app by passing in an options object and an optional showVenueOptions object.

The options object contains your venue, clientId, clientSecret, optional headers etc. To get you started we’ve provided a Mappedin Id and Secret that has access to some demo venues. When you’re ready 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.

clientIdSee Here
clientSecretSee Here

You can also 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
MPIOptions.Init("5eab30aa91b055001a68e996", "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
headers = listOf(MPIHeader("testName", "testValue"))),
MPIOptions.ShowVenue(labelAllLocationsOnInit = true, backgroundColor = "#CDCDCD")

showVenue is an alternative method to load the venue without using any API calls to retrieve the data. Instead, the data must be passed into the showVenue method which takes in a data string (which can be retrieved from a file).

Use this sample JSON file to get started with the showVenue method.

Here is an example:

// use showVenue to load venue
val venueDataJson ="mappedin-demo-mall.json").bufferedReader().use {
MPIOptions.ShowVenue(labelAllLocationsOnInit = true, backgroundColor = "#CDCDCD")

You should see something that looks like this in the Android Emulator:

And zooming in to have a closer look:

Search Our Docs

Sign Up

© 2020 Copyright Mappedin, All Rights Reserved. View our Privacy Policy