---
title: "search(query, callback, options)"
framework: mapkitjs
role: symbol
role_heading: Instance Method
path: mapkitjs/search/search1
---

# search(query, callback, options)

Retrieves the results of a search query.

## Declaration

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

## Parameters

- `query`: A string or a doc://com.apple.mapkitjs/documentation/MapKitJS/SearchAutocompleteResult.
- `callback`: A callback function or delegate object.
- `options`: With the doc://com.apple.mapkitjs/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 doc://com.apple.mapkitjs/documentation/MapKitJS/Search constructor. Another option is doc://com.apple.mapkitjs/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

Return Value A promise that resolves when the search completes.

## Discussion

Discussion The search(query, callback, options) method returns a set of locations that matches a user-entered query or a 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). An object that contains query, boundingRegion, and places properties. The data properties include: query (String). The query that corresponds to the results, if you don’t use SearchAutocompleteResult to perform the search. Optional. boundingRegion (CoordinateRegion). A region that encloses the search results. This property isn’t present if there aren’t any results. places (array of Place). An array of 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: 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); });

## See Also

### Deprecated

- [autocomplete(query, callback, options)](mapkitjs/search/autocomplete1.md)
- [cancel(promise)](mapkitjs/service/cancel.md)
- [RegionPriority](mapkitjs/search/regionpriority-data.var.md)
