This documentation refers to the introduced concept of select and highlight that was released with SDK 4.3.0
Last updated
Was this helpful?
How to change the appearance of different states
The MapsIndoors Android SDK supports Select and Highlight Display Rules and they can be retrieved and edited through MapsIndoors.
Example
// Changing the visibility of a polygon for selection
MapsIndoors.getDisplayRule(MPSolutionDisplayRule.SELECTION)?.let {
it.isPolygonVisible = true
}
// Changing the visibility of a label for highlights
MapsIndoors.getDisplayRule(MPSolutionDisplayRule.HIGHLIGHT)?.let {
it.isLabelVisible = false
}
Highlight
Highlight all Restrooms
// Create a filter to only receive locations with the category Toilet
val filter = MPFilter.Builder().setCategories(Collections.singletonList("Toilet")).build()
// Query locations with the created filter
MapsIndoors.getLocationsAsync(null, filter) { locations, error ->
if (locations != null) {
// Highliting all current toilets, with default MPHighlightBehavior.
// The MPHighlightBehavior can be used to customize the camera and map behavior,
// like fitting the view to show all highlighted locations.
mMapControl?.setHighlight(locations, MPHighlightBehavior.DEFAULT)
}
}
Clear the highlight
mMapControl?.clearHighlight()
Styling the Highlight Badge
The new Highlight Display Rule has a collection of new properties that can be used to change the style of the Highlight badge. You can see all current Display Rule properties in the reference documentation.
You can easily change the icon to an image of your liking. In this example it is assumed that you have a method getSelectionBitmap() that loads, fetches or generates the image you want to use.
val myBitmap = getSelectionBitmap()
MapsIndoors.getDisplayRule(MPSolutionDisplayRule.SELECTION)?.apply {
setIcon(myBitmap)
}
mapControl?.selectLocation(loc, MPSelectionBehavior.DEFAULT)
Deprecated Selection Highlight
Before the release of 4.3.0 the Android SDK already had a visual implementation of selection with a Display Rule. This is the MPSolutionDisplayRule.SELECTION_HIGHLIGHT that can also be changed like the newly introduced MPSolutionDisplayRule. If you want to retain the old selection rendering, it can be toggled through the Solution Config on the SDK.
Note that the isNewSelection setting lives on the Solution, so with any subsequent load of MapsIndoors it will be necessary to set the value to false again, as it defaults to true.
An example of the highlight solution Display Rule in action
An example of the selection solution DisplayRule in action