From 5f58046050c2c06f6409ef6f0e1d4c2ddefd97fb Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Mon, 18 Aug 2025 08:42:34 +0200 Subject: [PATCH 1/5] Added article for additional details --- SUMMARY.md | 1 + .../android/additional-location-details.md | 179 ++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 sdks-and-frameworks/android/additional-location-details.md diff --git a/SUMMARY.md b/SUMMARY.md index 73f0e0e..fc84488 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -88,6 +88,7 @@ * [Integrating MapsIndoors into your own App](sdks-and-frameworks/android/getting-started/integrating-mapsindoors-into-your-own-app.md) * [Migrating from V3 to V4](sdks-and-frameworks/android/getting-started/migrating-from-v3-to-v4/README.md) * [Migrating to Mapbox V11](sdks-and-frameworks/android/getting-started/migrating-from-v3-to-v4/migrating-to-mapbox-v11.md) + * [Additional Location Details](sdks-and-frameworks/android/additional-location-details.md) * [Directions](sdks-and-frameworks/android/directions/README.md) * [Directions Service](sdks-and-frameworks/android/directions/directions-service.md) * [Directions Renderer](sdks-and-frameworks/android/directions/directions-renderer/README.md) diff --git a/sdks-and-frameworks/android/additional-location-details.md b/sdks-and-frameworks/android/additional-location-details.md new file mode 100644 index 0000000..397fdf9 --- /dev/null +++ b/sdks-and-frameworks/android/additional-location-details.md @@ -0,0 +1,179 @@ + +# 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 article](products/cms/additional-location-details.md) 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. + +{% code title="Print all details example" overflow="wrap" lineNumbers="true" %} +```kotlin +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}" + } + ) + } +} +``` +{% endcode %} + +> **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 mutile phone numbers: customer service and sales with the respective keys `customerService` and `sales`, you can filter and print them by key: + +{% code title="Print specific phone numbers example" overflow="wrap" lineNumbers="true" %} +```kotlin +fun printPhoneNumbers(location: MPLocation) { + // Get the list of additional details + val details = location.additionalDetails + if (details.isNullOrEmpty()) return + + // Filter for phone number details + details.filter { it.detailType == MPDetailType.Phone }.forEach { phoneDetail -> + // Print a message based on the key + when (phoneDetail.key) { + "customerService" -> print("Reach Customer Service: ${phoneDetail.value}") + "sales" -> print("Reach Sales: ${phoneDetail.value}") + else -> print("Reach ${phoneDetail.displayText} number: ${phoneDetail.value}") + } + } +} +``` +{% endcode %} + +--- + +## 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 + +{% code title="PhoneNumbersList composable" overflow="wrap" lineNumbers="true" %} +```kotlin +@Composable +fun PhoneNumbersList(location: MPLocation) { + // Filter for phone number details + val phoneDetails = location.additionalDetails + ?.filter { it.detailType == MPDetailType.Phone } + .orEmpty() + + if (phoneDetails.isEmpty()) { + // Show a message if there are no phone numbers + Text("No phone numbers available") + return + } + + // Display each phone number in a column + Column { + phoneDetails.forEach { detail -> + // Choose a label based on the key + val label = when (detail.key) { + "customerService" -> "Customer Service" + "sales" -> "Sales" + else -> detail.displayText ?: "Other" + } + // Show the label and value + Text("$label: ${detail.value}") + } + } +} +``` +{% endcode %} + +--- + +### 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: + +{% code title="LocationDetailsList composable" overflow="wrap" lineNumbers="true" %} +```kotlin +@Composable +fun LocationDetailsList(location: MPLocation) { + // Get all active details for the location + val details = location.additionalDetails.orEmpty().filter { it.active == true } + + if (details.isEmpty()) { + // Show a message if there are no details + Text("No details available") + return + } + + // Display all details in a column, sorted by type for grouping + Column { + details.sortedBy { it.detailType?.ordinal ?: 0 }.forEach { detail -> + when (detail.detailType) { + MPDetailType.Phone -> { + // Show phone numbers with a label based on the key + val label = when (detail.key) { + "customerService" -> "Customer Service" + "sales" -> "Sales" + else -> detail.displayText ?: "Other Phone" + } + Text("$label: ${detail.value}") + } + MPDetailType.Email -> { + // Show email address + Text("Email: ${detail.value}") + } + MPDetailType.URL -> { + // Show website with display text if available + val label = detail.displayText ?: "Website" + Text("$label: ${detail.value}") + } + MPDetailType.Text -> { + // Show generic text info + Text("Info: ${detail.value}") + } + MPDetailType.OpeningHours -> { + // Show opening hours, or N/A if missing + Text("Opening hours: ${detail.openingHours?.toString() ?: "N/A"}") + } + else -> { + // Fallback for unknown types + Text("Other: ${detail.value}") + } + } + } + } +} +``` +{% endcode %} + +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. From 64a431921418fedf588070bf8df3723efd7d8e74 Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Mon, 18 Aug 2025 12:33:34 +0200 Subject: [PATCH 2/5] Update sdks-and-frameworks/android/additional-location-details.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- sdks-and-frameworks/android/additional-location-details.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks-and-frameworks/android/additional-location-details.md b/sdks-and-frameworks/android/additional-location-details.md index 397fdf9..282c4cd 100644 --- a/sdks-and-frameworks/android/additional-location-details.md +++ b/sdks-and-frameworks/android/additional-location-details.md @@ -54,7 +54,7 @@ fun printDetails(location: MPLocation) { ### Filtering and Printing Specific Details -Your locations can have multiple details, in this case the location has mutile phone numbers: customer service and sales with the respective keys `customerService` and `sales`, you can filter and print them by key: +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: {% code title="Print specific phone numbers example" overflow="wrap" lineNumbers="true" %} ```kotlin From c8bbcde6f7a3a148087dc177dd877bf6ef72bb74 Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Tue, 19 Aug 2025 09:50:45 +0200 Subject: [PATCH 3/5] moved link below search in summary --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index fc84488..cc43be9 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -88,7 +88,6 @@ * [Integrating MapsIndoors into your own App](sdks-and-frameworks/android/getting-started/integrating-mapsindoors-into-your-own-app.md) * [Migrating from V3 to V4](sdks-and-frameworks/android/getting-started/migrating-from-v3-to-v4/README.md) * [Migrating to Mapbox V11](sdks-and-frameworks/android/getting-started/migrating-from-v3-to-v4/migrating-to-mapbox-v11.md) - * [Additional Location Details](sdks-and-frameworks/android/additional-location-details.md) * [Directions](sdks-and-frameworks/android/directions/README.md) * [Directions Service](sdks-and-frameworks/android/directions/directions-service.md) * [Directions Renderer](sdks-and-frameworks/android/directions/directions-renderer/README.md) @@ -101,6 +100,7 @@ * [Searching](sdks-and-frameworks/android/searching/README.md) * [Searching on a Map](sdks-and-frameworks/android/searching/searching-on-a-map.md) * [Creating a Search Experience](sdks-and-frameworks/android/searching/creating-a-search-experience.md) + * [Additional Location Details](sdks-and-frameworks/android/additional-location-details.md) * [Live Data](sdks-and-frameworks/android/live-data/README.md) * [Webex Integration](sdks-and-frameworks/android/live-data/webex-integration.md) * [Live Data in Practice](sdks-and-frameworks/android/live-data/live-data-in-practice.md) From e7d5ed3a88264e3f2fe7d8464761292afe2e40e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20=C3=98sterby=20Hansen?= Date: Tue, 19 Aug 2025 15:15:57 +0200 Subject: [PATCH 4/5] added additional details docs for ios --- SUMMARY.md | 1 + .../ios/additional-location-details.md | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 sdks-and-frameworks/ios/additional-location-details.md diff --git a/SUMMARY.md b/SUMMARY.md index cc43be9..c1376df 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -148,6 +148,7 @@ * [Enable Live Data](sdks-and-frameworks/ios/getting-started/enable-live-data.md) * [Integrating MapsIndoors into your own App](sdks-and-frameworks/ios/getting-started/integrating-mapsindoors-into-your-own-app.md) * [Migrating from v3 to v4](sdks-and-frameworks/ios/getting-started/migrating-from-v3-to-v4.md) + * [Additional Location Details](sdks-and-frameworks/ios/additional-location-details.md) * [Directions](sdks-and-frameworks/ios/directions/README.md) * [Directions Renderer](sdks-and-frameworks/ios/directions/directions-renderer/README.md) * [User's Location as Point of Origin](sdks-and-frameworks/ios/directions/directions-renderer/users-location-as-point-of-origin.md) diff --git a/sdks-and-frameworks/ios/additional-location-details.md b/sdks-and-frameworks/ios/additional-location-details.md new file mode 100644 index 0000000..de06e42 --- /dev/null +++ b/sdks-and-frameworks/ios/additional-location-details.md @@ -0,0 +1,72 @@ + +# 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 article](products/cms/additional-location-details.md) for how to set them up or edit them. + +--- + +## 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. + +{% code title="Print all details example" overflow="wrap" lineNumbers="true" %} +```swift +func printDetails(location: MPLocation) { + // Get and iterate over the list of additional details from the location + for detail in location.additionalDetails ?? [] { + // Only print active details + guard detail.active ?? false else { continue } + + let string = switch detail.detailType?.type { + case .text: + // Text details (e.g. description) + "\(location.name) additional information: \(detail.value ?? "nil")" + case .phone: + // Phone details (all details have a key for identification) + "\(location.name)'s phone number (\(detail.key ?? "nil")): \(detail.value ?? "nil")" + case .url: + // URL details (details can have user friendly display text) + "\(location.name)'s website: \(detail.value ?? "nil") (label: \(detail.displayText ?? "nil"))" + case .email: + // Email details (details can be supplied with an icon URL) + "\(location.name)'s email: \(detail.value ?? "nil") (icon: \(detail.icon ?? "nil"))" + case .openingHours: + // Opening hours (has a special field 'openingHours' that is only used for this + "\(location.name) opening hours: \(detail.openingHours?.description ?? "No opening hours")" + case .none: + "Unknown detail type for \(location.name)" + case .some(_): + "Unknown detail type for \(location.name)" + } + print(string) + } +} +``` +{% endcode %} + +> **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: + +{% code title="Print specific phone numbers example" overflow="wrap" lineNumbers="true" %} +```swift +func printPhoneNumbers(location: MPLocation) { + // Get the list of additional details + guard let details = location.additionalDetails else { return } + + // Filter details of type "phone", and print messages for each custom key in your data + details.filter { $0.detailType?.type == .phone }.forEach { detail in + switch detail.key { + case "customerService": + print("Customer Service: \(detail.value ?? "N/A")") + case "sales": + print("Sales: \(detail.value ?? "N/A")") + default: + print("Phone (\(detail.key ?? "N/A")): \(detail.value ?? "N/A")") + } + } +} +``` +{% endcode %} \ No newline at end of file From a39a543e9fbbea6295d368897d84a13dde214e0b Mon Sep 17 00:00:00 2001 From: Frederik Hansen <72246003+fhansenMP@users.noreply.github.com> Date: Tue, 14 Oct 2025 10:38:39 +0200 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Christian Wolf Johannsen <85162337+ChristianWolf-mapspeople@users.noreply.github.com> --- sdks-and-frameworks/ios/additional-location-details.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks-and-frameworks/ios/additional-location-details.md b/sdks-and-frameworks/ios/additional-location-details.md index de06e42..9dde83a 100644 --- a/sdks-and-frameworks/ios/additional-location-details.md +++ b/sdks-and-frameworks/ios/additional-location-details.md @@ -31,7 +31,7 @@ func printDetails(location: MPLocation) { // Email details (details can be supplied with an icon URL) "\(location.name)'s email: \(detail.value ?? "nil") (icon: \(detail.icon ?? "nil"))" case .openingHours: - // Opening hours (has a special field 'openingHours' that is only used for this + // Opening hours (has a special field 'openingHours' that is only used for this) "\(location.name) opening hours: \(detail.openingHours?.description ?? "No opening hours")" case .none: "Unknown detail type for \(location.name)"