From b26f48574cc76dfa89399d89a38dc67bd2b0378e Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Tue, 12 Aug 2025 13:07:31 +0200 Subject: [PATCH 1/5] Added nested categories for search Fixed tabbing in searching --- .../android/searching/README.md | 138 ++++++++++++++---- 1 file changed, 106 insertions(+), 32 deletions(-) diff --git a/sdks-and-frameworks/android/searching/README.md b/sdks-and-frameworks/android/searching/README.md index 92f66968..b531f0e8 100644 --- a/sdks-and-frameworks/android/searching/README.md +++ b/sdks-and-frameworks/android/searching/README.md @@ -28,11 +28,15 @@ See the full list of parameters: #### + +#### Example of Creating a Search Query + {% tabs %} + {% tab title="Java" %} -#### Example of Creating a Search Query -``` +{% code overflow="wrap" lineNumbers="true" %} +```java void findRestroom() { //Here we will create an empty query because we are only interrested in getting locations that match a category. If you want to be more specific here where you can add a query text like "Unisex Restroom" MPQuery mpQuery = new MPQuery @@ -54,41 +58,14 @@ void findRestroom() { }); } ``` +{% endcode %} -### Display Search Results on the Map[​](https://docs.mapsindoors.com/searching#display-search-results-on-the-map) - -When displaying the search results it is helpful to filter the map to only show matching Locations. Matching Buildings and Venues will still be shown on the map, as they give context to the user, even if they aren't selectable on the map. - -#### Example of Filtering the Map to Display Searched Locations on the Map - - - -``` -MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (locations, error) -> { - if (locations != null && !locations.isEmpty()) { - //Query with the locations from the query result. Use default camera behavior - mMapControl.setFilter(locations, MPFilterBehavior.DEFAULT); - } -}); -``` - -### Clearing the Map of Your Filter[​](https://docs.mapsindoors.com/searching#clearing-the-map-of-your-filter) - -After displaying the search results on your map you can then clear the filter so that all Locations show up on the map again. - -#### Example of Clearing Your Map Filter to Show All Locations Again - -``` -mMapControl.clearFilter(); -``` {% endtab %} {% tab title="Kotlin" %} -#### Example of Creating a Search Query - - -``` +{% code overflow="wrap" lineNumbers="true" %} +```kotlin fun findRestroom() { //Here we will create an empty query because we are only interrested in getting locations that match a category. If you want to be more specific here where you can add a query text like "Unisex Restroom" val mpQuery = MPQuery.Builder() @@ -107,6 +84,11 @@ fun findRestroom() { } } ``` +{% endcode %} + +{% endtab %} + +{% endtabs %} ### Display Search Results on the Map[​](https://docs.mapsindoors.com/searching#display-search-results-on-the-map) @@ -114,14 +96,37 @@ When displaying the search results it is helpful to filter the map to only show #### Example of Filtering the Map to Display Searched Locations on the Map +{% tabs %} +{% tab title="Java" %} +{% code overflow="wrap" lineNumbers="true" %} +```java +MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (locations, error) -> { + if (locations != null && !locations.isEmpty()) { + //Query with the locations from the query result. Use default camera behavior + mMapControl.setFilter(locations, MPFilterBehavior.DEFAULT); + } +}); ``` +{% endcode %} + +{% endtab %} + +{% tab title="Kotlin" %} + +{% code overflow="wrap" lineNumbers="true" %} +```kotlin MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (locations, error) -> { //Query with the locations from the query result. Use default camera behavior mMapControl.setFilter(locations, MPFilterBehavior.DEFAULT) }); ``` +{% endcode %} + +{% endtab %} + +{% endtabs %} ### Clearing the Map of Your Filter[​](https://docs.mapsindoors.com/searching#clearing-the-map-of-your-filter) @@ -129,9 +134,78 @@ After displaying the search results on your map you can then clear the filter so #### Example of Clearing Your Map Filter to Show All Locations Again +{% tabs %} + +{% tab title="Java" %} + +{% code overflow="wrap" lineNumbers="true" %} +```java +mMapControl.clearFilter(); ``` +{% endcode %} + +{% endtab %} + +{% tab title="Kotlin" %} + +{% code overflow="wrap" lineNumbers="true" %} +```kotlin mMapControl.clearFilter() ``` +{% endcode %} + {% endtab %} + {% endtabs %} +### Searching for Nested Categories + +If you have set up nested categories in your solution, then it has become much easier to search for these categories than before, but it might not make sense right now, lets go over it with an example: + +You have three categories: `Restroom`, `Unisex`, and `Handicap`. Of these three, `Unisex` and `Handicap` are sub categories of `Restroom`. + +before we get to searching, lets see what we can do in the SDK: + +{% code overflow="wrap" lineNumbers="true" %} +```kotlin +val categoryCollection = MapsIndoors.getCategories() + + +// chech whether a category has a named child category +val isChild = categoryCollection?.getCategory("Restroom")?.hasChild("Unisex") +if (isChild == true) { + print("Restroom has a child with the key 'Unisex'!") +} + +// fetch sub-categories with the child keys +val keys = categoryCollection?.getCategory("Restroom").childKeys +for (key in keys ?: emptyList()) { + val category = categoryCollection?.getCategory(key) + if (category != null) { + print("Restroom has category ${category.value} as a child!") + } +} +``` +{% endcode %} + +Now, the above example is not necessary when searching with nested categories, the approach is actually quite simple. When searching for a specific category, all its sub-categories, its children, are automatically added to the query. This means if you search for locations in the category `Restroom`, you will also find all locations with the categories `Unisex` and `Handicap`, thus there is no setup needed for searching with nested categories. Lets see it in action: + +{% code overflow="wrap" lineNumbers="true" %} +```kotlin +// we are only searching for the category, so lets set an empty query +val query = MPQuery.Builder().build() +// add the super-category Restroom to the list of categories +val filter = MPFilter.Builder().setCategories(listOf("Restroom")).build() + +MapsIndoors.getLocationsAsync(query, filter) { locations, error -> + + // lets see if we have found any Locations that have the type "Unisex" + if (locations?.any { loc -> loc.categories?.any { cat -> cat == "Unisex" } == true } == true) { + // success + print("Locations with Unisex category found") + } +} +``` +{% endcode %} + +It is important to note that when searching for a category, then all sub-categories will be included in the search space. If that is not the wanted experience, the solution is quite simply to create a new sub-category that contains the expected locations, and using that for searching. From 021bd3298a67264db889ce1d0af8d547f877aec3 Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Tue, 12 Aug 2025 13:08:29 +0200 Subject: [PATCH 2/5] update --- sdks-and-frameworks/android/searching/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks-and-frameworks/android/searching/README.md b/sdks-and-frameworks/android/searching/README.md index b531f0e8..a9a43444 100644 --- a/sdks-and-frameworks/android/searching/README.md +++ b/sdks-and-frameworks/android/searching/README.md @@ -162,7 +162,7 @@ mMapControl.clearFilter() If you have set up nested categories in your solution, then it has become much easier to search for these categories than before, but it might not make sense right now, lets go over it with an example: -You have three categories: `Restroom`, `Unisex`, and `Handicap`. Of these three, `Unisex` and `Handicap` are sub categories of `Restroom`. +You have three categories: `Restroom`, `Unisex`, and `Handicap`. Of these three, `Unisex` and `Handicap` are sub-categories of `Restroom`. before we get to searching, lets see what we can do in the SDK: @@ -172,7 +172,7 @@ val categoryCollection = MapsIndoors.getCategories() // chech whether a category has a named child category -val isChild = categoryCollection?.getCategory("Restroom")?.hasChild("Unisex") +val isChild = categoryCollection?.getCategory("Restroom")?.childKeys?.contains("Unisex") if (isChild == true) { print("Restroom has a child with the key 'Unisex'!") } From e6689517d877514022515968a3e1215f836036db Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Mon, 18 Aug 2025 08:57:58 +0200 Subject: [PATCH 3/5] Improved the article with AI --- .../android/searching/README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sdks-and-frameworks/android/searching/README.md b/sdks-and-frameworks/android/searching/README.md index a9a43444..496befda 100644 --- a/sdks-and-frameworks/android/searching/README.md +++ b/sdks-and-frameworks/android/searching/README.md @@ -160,18 +160,19 @@ mMapControl.clearFilter() ### Searching for Nested Categories -If you have set up nested categories in your solution, then it has become much easier to search for these categories than before, but it might not make sense right now, lets go over it with an example: +If your solution uses nested categories, searching for them is now much more intuitive. When you search for a parent category, all of its sub-categories are automatically included in the search—no extra setup is required. -You have three categories: `Restroom`, `Unisex`, and `Handicap`. Of these three, `Unisex` and `Handicap` are sub-categories of `Restroom`. +#### Understanding Nested Categories -before we get to searching, lets see what we can do in the SDK: +Suppose you have three categories: `Restroom`, `Unisex`, and `Handicap`. Here, `Unisex` and `Handicap` are sub-categories of `Restroom`. This hierarchy allows you to organize your data more flexibly and makes searching more powerful. + +Before searching, you might want to inspect the category structure in the SDK. For example, you can check if a category has specific children, or list all sub-categories: {% code overflow="wrap" lineNumbers="true" %} ```kotlin val categoryCollection = MapsIndoors.getCategories() - -// chech whether a category has a named child category +// check whether a category has a named child category val isChild = categoryCollection?.getCategory("Restroom")?.childKeys?.contains("Unisex") if (isChild == true) { print("Restroom has a child with the key 'Unisex'!") @@ -188,7 +189,9 @@ for (key in keys ?: emptyList()) { ``` {% endcode %} -Now, the above example is not necessary when searching with nested categories, the approach is actually quite simple. When searching for a specific category, all its sub-categories, its children, are automatically added to the query. This means if you search for locations in the category `Restroom`, you will also find all locations with the categories `Unisex` and `Handicap`, thus there is no setup needed for searching with nested categories. Lets see it in action: +#### Searching with Nested Categories + +When you perform a search for a parent category, such as `Restroom`, the SDK will automatically include all its sub-categories (`Unisex`, `Handicap`, etc.) in the search results. This means you only need to specify the parent category in your filter, and all relevant locations will be found. {% code overflow="wrap" lineNumbers="true" %} ```kotlin @@ -208,4 +211,5 @@ MapsIndoors.getLocationsAsync(query, filter) { locations, error -> ``` {% endcode %} -It is important to note that when searching for a category, then all sub-categories will be included in the search space. If that is not the wanted experience, the solution is quite simply to create a new sub-category that contains the expected locations, and using that for searching. + +> **Note:** When you search for a parent category, all of its sub-categories are always included in the results, there is no way to limit the search to only the parent category itself. If you need more granular control (for example, to only return locations with a specific sub-category), consider organizing your categories so that each search target has its own unique sub-category. This way, you can search for exactly the locations you want by specifying the appropriate sub-category in your filter. \ No newline at end of file From 12e763d8f5e3cf53f8112092578be03bea9245e0 Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Mon, 18 Aug 2025 12:38:51 +0200 Subject: [PATCH 4/5] Fixed spelling error and code error --- sdks-and-frameworks/android/searching/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdks-and-frameworks/android/searching/README.md b/sdks-and-frameworks/android/searching/README.md index 496befda..081c7abe 100644 --- a/sdks-and-frameworks/android/searching/README.md +++ b/sdks-and-frameworks/android/searching/README.md @@ -38,7 +38,7 @@ See the full list of parameters: {% code overflow="wrap" lineNumbers="true" %} ```java void findRestroom() { - //Here we will create an empty query because we are only interrested in getting locations that match a category. If you want to be more specific here where you can add a query text like "Unisex Restroom" + //Here we will create an empty query because we are only interested in getting locations that match a category. If you want to be more specific here where you can add a query text like "Unisex Restroom" MPQuery mpQuery = new MPQuery .Builder() .build(); @@ -117,10 +117,10 @@ MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (locations, error) -> { {% code overflow="wrap" lineNumbers="true" %} ```kotlin -MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (locations, error) -> { +MapsIndoors.getLocationsAsync(mpQuery, mpFilter) { locations, error -> //Query with the locations from the query result. Use default camera behavior mMapControl.setFilter(locations, MPFilterBehavior.DEFAULT) -}); +}; ``` {% endcode %} From 50a3454b1202369302955b7120b04784fc2f04eb Mon Sep 17 00:00:00 2001 From: Matias Dahlin Holst Date: Tue, 19 Aug 2025 09:47:48 +0200 Subject: [PATCH 5/5] Fixed missing tag --- sdks-and-frameworks/android/searching/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks-and-frameworks/android/searching/README.md b/sdks-and-frameworks/android/searching/README.md index 081c7abe..ca8f1190 100644 --- a/sdks-and-frameworks/android/searching/README.md +++ b/sdks-and-frameworks/android/searching/README.md @@ -158,7 +158,7 @@ mMapControl.clearFilter() {% endtabs %} -### Searching for Nested Categories +### Searching for Nested Categories If your solution uses nested categories, searching for them is now much more intuitive. When you search for a parent category, all of its sub-categories are automatically included in the search—no extra setup is required.