Additional Location Details

MapsIndoors locations can have a variety of additional details, such as phone numbers, websites, emails, and opening hours. These details can be managed in the CMS, read this articlearrow-up-right for how to set them up or edit them.

This guide shows how to access and display these details in your Android app, both in code and in a Jetpack Compose UI.


Accessing Additional Details in Code

Each MPLocation object contains an additionalDetails property, which is a list of detail objects. Each detail has a type, value, key, and other fields. You can iterate through these details and handle them according to their type.

Print all details example
fun printDetails(location: MPLocation) {
    // Get the list of additional details from the location
    val details = location.additionalDetails
    if (details.isNullOrEmpty()) return // No details to print

    for (detail in details) {
        // Only print active details
        if (detail.active != true) continue

        // Print a message depending on the detail type
        print(
            when (detail.detailType) {
                MPDetailType.Text ->
                    // Text details (e.g. description)
                    "${location.name} additional information: ${detail.value}"
                MPDetailType.Phone ->
                    // Phone details (all details have a key for identification)
                    "${location.name}'s phone number (${detail.key}): ${detail.value}"
                MPDetailType.URL ->
                    // URL details (details can have user friendly display text)
                    "${location.name}'s website: ${detail.value} (label: ${detail.displayText})"
                MPDetailType.Email ->
                    // Email details (details can be supplied with an icon URL)
                    "${location.name}'s email: ${detail.value} (icon: ${detail.icon})"
                MPDetailType.OpeningHours ->
                    // Opening hours (has a special field 'openingHours' that is only used for this)
                    "${location.name} opening hours: ${detail.openingHours?.toString()}"
                null ->
                    // Unknown detail type
                    "Unknown detail type for ${location.name}"
            }
        )
    }
}

Note: A single location can have multiple details of the same type. Use unique keys to distinguish them.

Filtering and Printing Specific Details

Your locations can have multiple details, in this case the location has multiple phone numbers: customer service and sales with the respective keys customerService and sales, you can filter and print them by key:


Displaying Additional Details in Jetpack Compose UI

You can present additional details in your app's UI using Jetpack Compose. Below are two examples: one for showing all phone numbers, and one for showing all details in a single list.

Example: Show All Phone Numbers


Example: Show All Details in a Single UI

You can display all available details for a location in a single composable. This example shows phone numbers, emails, URLs, text, and opening hours in a unified list, with comments explaining each step:

This composable will show all the different types of additional details for a location in a single list, making it easy to present all relevant information to the user.

Last updated

Was this helpful?