> 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/getting-started/search.md).

# Search

### Search for a Location​ <a href="#search-for-a-location" id="search-for-a-location"></a>

From here onwards, code for both Mapbox and Google Map`s` is similar.

Take a look at the following code. As discussed before, this will select a location specifically named "The Crow".

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController.swift#L28-L35>" %}

Our goal now is to enable the user to interact with a search bar and move the map with respect to their search. Therefore, we need to implement a bit more functionality in our ViewController class, so feel free to update it as follows.

```swift
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate {
...
}
```

Let us start off by implementing the search bar. In this case, we add the following variables to our `ViewController` class. The tableView will be used to allow the user to see and interact with the search results.

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController.swift#L86-L87>" %}

And let us also make sure the search bar is correctly displayed in our view and the `ViewController` is its delegate.

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ExampleUI.swift#L19-L31>" %}

Finally, let us add the functions necessary for our class to conform to the `UISearchBarDelegate` and `UITableViewDataSource` protocols for the actual search button functionality.

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController%2BUISearchBarDelegate.swift>" %}

This responds to what the user enters in the search bar and tells MapsIndoors to search for the entered text and show the found Locations in the table view. This is almost exactly the same as the initial simple search we included in [Display a Map](https://docs.mapsindoors.com/getting-started/ios/display-a-map/) with MapsIndoors.

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController%2BUITableViewDataSource.swift>" %}

These three functions simply outline the appearance of the table. Namely, how many rows to show and which text to represent each entry.

{% @github-files/github-code-block url="<https://github.com/MapsPeople/MapsIndoorsGettingStarted-Mapbox/blob/12aaf3c15d8516842e76effddec95416f3a7e3c4/MapsIndoorsGettingStarted-Mapbox/ViewController%2BUITableViewDelegate.swift>" %}

This instructs what to do once an item is selected – in this case we simply go to the specified Location and hide the table view again.

At this point we should have a functional map with a search feature.

### Expected Result​ <a href="#expected-result" id="expected-result"></a>

<figure><img src="https://2554025873-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYZLXDaaclvaSK6Q7eigW%2Fuploads%2Fgit-blob-e6b9260be9108dfb9b36ba96aba07a9491cf92aa%2FiOS%20Search%20result.gif?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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/getting-started/search.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.
