> For the complete documentation index, see [llms.txt](https://docs.mapsindoors.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mapsindoors.com/sdks-and-frameworks/ios/highlight-and-select.md).

# Highlight and Select

This documentation refers to the introduced concept of select and highlight that was released with SDK 4.3.0.

## How to change the appearance of different states <a href="#how-to-change-the-appearance-of-different-states" id="how-to-change-the-appearance-of-different-states"></a>

The MapsIndoors iOS SDK supports Select and Highlight Display Rules and they can be retrieved and edited through `MPMapsIndoors.shared`.

#### **Example**

```swift
// Changing the visibility of a polygon for selection
if let displayRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .selection) {
    displayRule.polygonVisible = true
}

​// Changing the visibility of a label for highlights
if let displayRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .highlight) {
    displayRule.labelVisible = false
}
```

## Highlight <a href="#highlight" id="highlight"></a>

### **Highlight all Restrooms**

```swift
// Create a filter to only receive locations with the category Toilet
let filter =  MPFilter()
filter.categories = ["Toilet"]

// Query locations with the created filter
let locations = await MPMapsIndoors.shared.locationsWith(query: nil, filter: filter)

// Highlighting all current toilets, with the default MPHighlightBehavior.
// The MPHighlightBehavior can be used to customize the camera and map behavior,
// like fitting the view to show all highlighted locations.
mapControl?.setHighlight(locations: locations, behavior: .default)
```

<figure><img src="https://2554025873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYZLXDaaclvaSK6Q7eigW%2Fuploads%2Fgit-blob-f5a4a8830772b4d6a340537b094e308b02a92a94%2Fios-highlighted-locations.jpg?alt=media" alt="" width="563"><figcaption><p>An example of the highlight solution Display Rule in action</p></figcaption></figure>

#### Clear the highlight

```swift
mapControl?.clearHighlight()
```

### Styling the Highlight Badge <a href="#selection" id="selection"></a>

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](https://app.mapsindoors.com/mapsindoors/reference/ios/4.9.6/documentation/mapsindoors/mpdisplayrule#instance-properties).

#### Example: Change the color of the Highlight Badge

```swift
if let highlightRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .highlight) {
    highlightRule.badgeFillColor = .blue
    highlightRule.badgeStrokeColor = .red
}
mapControl?.setHighlight(locations: [loc], behavior: .default)
```

#### Example: Hide the Highlight Badge

```swift
if let highlightRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .highlight) {
    highlightRule.badgeVisible = false
}
mapControl?.setHighlight(locations: [loc], behavior: .default)
```

## Selection <a href="#selection" id="selection"></a>

The selection Display Rule is for changing the appearance of single selected Location, for example when the user clicks on it. To select a Location programmatically, call the method [MPMapControl.select(location:behavior)](https://app.mapsindoors.com/mapsindoors/reference/ios/4.9.6/documentation/mapsindoors/mpmapcontrol/select\(location:behavior:\)/)

```swift
mapControl?.select(location: location, behavior: .default)
```

<figure><img src="https://2554025873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYZLXDaaclvaSK6Q7eigW%2Fuploads%2Fgit-blob-91831a1c2fb66b6a91b138d147513b7e3b61ef44%2Fios-selected-location.jpg?alt=media" alt="" width="563"><figcaption><p>An example of the selection solution DisplayRule in action</p></figcaption></figure>

#### **Clear current Selection**

```swift
mapControl?.select(location: nil, behavior: .default)
```

### Styling the Selection Marker <a href="#previous-selection" id="previous-selection"></a>

You can easily change the icon to an image from your app Asset Catalogue. In this example it is assumed that you have an image in the project Asset Catalogue named `selectionIcon`:

```swift
if let selectionRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .selection) {
    selectionRule.icon = UIImage(named: "selectionIcon")
}
mapControl?.select(location: loc, behavior: .default)
```

<figure><img src="https://2554025873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYZLXDaaclvaSK6Q7eigW%2Fuploads%2Fgit-blob-9fe12fd696c7e8f40f273869f07330150e249a49%2FcustomSelectionIcon.png?alt=media" alt="" width="375"><figcaption><p>Example of a custom Selection Marker.</p></figcaption></figure>

## Deprecated Selection Highlight <a href="#previous-selection" id="previous-selection"></a>

Before the release of 4.3.0 the MapsIndoors SDK already had a visual implementation of selection with a Display Rule. That Display Rule can also be changed like the newly introduced Selection Display Rule. If you want to retain the old selection rendering, it can be toggled through the Solution Config on the SDK.

#### **Example**

```swift
MPMapsIndoors.shared.solution?.config.newSelection = false
let selectionRule = MPMapsIndoors.shared.displayRuleFor(displayRuleType: .selectionHighlight)
selectionRule?.polygonFillColor = .blue
selectionRule?.polygonFillOpacity = 0.2
selectionRule?.polygonStrokeWidth = 2.0
selectionRule?.polygonStrokeColor = .blue
selectionRule?.polygonVisible = true
selectionRule?.iconVisible = false
```

Note that the `newSelection` 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`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mapsindoors.com/sdks-and-frameworks/ios/highlight-and-select.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
