<!--
{
  "availability" : [
    "MapKit JS: 5.0.0 - 6.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/Search/search1",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "instm/mapkit.Search/search1"
  },
  "title" : "search(query, callback, options)"
}
-->

# search(query, callback, options)

Retrieves the results of a search query.

```
search(
    query: string | SearchAutocompleteResult,
    callback: SearchDelegate<SearchResponse>,
    options?: SearchOptions,
): Promise<SearchResponse>;
```

## Parameters

`query`

A `string` or a [`SearchAutocompleteResult`](/documentation/MapKitJS/SearchAutocompleteResult).

`callback`

A callback function or delegate object.

`options`

With the [`SearchOptions`](/documentation/MapKitJS/SearchOptions) hash, you can constrain the search to a desired area using the `coordinate` or `region` properties. A coordinate or region you supply here overrides the same property you supply to the [`Search`](/documentation/MapKitJS/Search) constructor. Another option is [`language`](/documentation/MapKitJS/SearchOptions/language). For example, `{ "language": "fr-CA" }` tells the server to send results localized to Canadian French. If you set it, this option overrides the language the system provides to the search constructor.

## Return Value

A promise that resolves when the search completes.

## Discussion

The [`search(query, callback, options)`](/documentation/MapKitJS/Search/search1) method returns a set of locations that matches a user-entered query or a [`SearchAutocompleteResult`](/documentation/MapKitJS/SearchAutocompleteResult).

MapKit JS invokes the `callback` function on failure and success with two arguments, `error` and `data`. If you cancel the request before you receive a response, the system doesn’t call this function. The callback can also be a delegate object.

The arguments are:

- `error` (`Error`). An error code and descriptive message.
- `data` ([`SearchResponse`](/documentation/MapKitJS/SearchResponse)). An object that contains [`query`](/documentation/MapKitJS/SearchResponse/query), [`boundingRegion`](/documentation/MapKitJS/SearchResponse/boundingRegion), and [`places`](/documentation/MapKitJS/SearchResponse/places) properties.

The `data` properties include:

- [`query`](/documentation/MapKitJS/SearchResponse/query) (`String`). The query that corresponds to the results, if you don’t use [`SearchAutocompleteResult`](/documentation/MapKitJS/SearchAutocompleteResult) to perform the search. Optional.
- [`boundingRegion`](/documentation/MapKitJS/SearchResponse/boundingRegion) ([`CoordinateRegion`](/documentation/MapKitJS/CoordinateRegion)). A region that encloses the search results. This property isn’t present if there aren’t any results.
- [`places`](/documentation/MapKitJS/SearchResponse/places) (array of [`Place`](/documentation/MapKitJS/Place)). An array of [`Place`](/documentation/MapKitJS/Place) objects. The places array is empty if there isn’t a match.

The following example searches for *coffee shop* in and around the visible map area, and adds the results as annotations:

```javascript
const search = new mapkit.Search({ region: map.region });

search.search("coffee shop", function(error, data) {
    if (error) {
        // Handle the search error.
        return;
    }
    const annotations = data.places.map(function(place) {
        const annotation = new mapkit.MarkerAnnotation(place.coordinate);
        annotation.title = place.name;
        annotation.subtitle = place.formattedAddress;
        annotation.color = "#9B6134";
        return annotation;
    });
    map.showItems(annotations);
});
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)