---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/GeoQueryResult.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# GeoQueryResult

Extends [IPromiseProvider](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IPromiseProvider.md).

Geo query result.

[Constructor](#constructor-summary) | [Methods](#methods-summary)

## Constructor {#constructor-summary}

```javascript
GeoQueryResult(source)
```

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`source`](#param-source)[*](*star) | — | Type: Object

Source of geo objects: 
- IGeoObject - Object that implements the corresponding interface.
- IGeoObject[] - Array of objects that implement the corresponding interface.
- ICollection - Collection of objects that implement the IGeoObject interface.
- ICollection[] - Array of object collections that implement the IGeoObject interface.
- IPromiseProvider - A promise object that passes the data source for geoQuery to the handler function. 	The handler function can also be passed an object with the geoObjects field containing the data source 	for geoQuery.
- GeoQueryResult - Object of the GeoQueryResult class.
- String\|Object - String or object with a JSON description of objects.
- Object[] - Array of JSON descriptions of geometries. An array item is an object with the 	"type" and "coordinates" fields. When describing a circle, the "radius" field is also mandatory. When describing a polygon, the optional "fillRule" field may also be specified.
JSON object descriptions are formed using the following approach (see the example below). An object may be an entity or a collection of entities. A collection of entities is made up of an object with the following fields: 
- type - Type of object. The value of the field must be "FeatureCollection".
- features - Array of child entities in the collection. Child objects may be entities or nested 	collections of entities.
An entity is made up of an object with the following fields: 
- type - Type of object. The value of the field must be "Feature".
- geometry - Object geometry. Contains the "type" and "coordinates" fields. Corresponds to the parameter 	passed to the constructor for the ymaps.GeoObject object.
- options - Options for the geo object.
- properties - Geo object data. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Creating GeoQueryResult from a single geo object.
var placemark = new ymaps.Placemark([34, 56]);
ymaps.geoQuery(placemark).addToMap(myMap);
```

**2.**

```javascript
// Creating GeoQueryResult from an array of geo objects.
var objects = [
    new ymaps.Placemark([34, 56]),
    new ymaps.Rectangle([[34, 56], [36, 57]])
];
ymaps.geoQuery(objects).addToMap(myMap);
```

**3.**

```javascript
// Creating GeoQueryResult from a collection of geo objects.
var result = ymaps.geoQuery(myMap.geoObjects).searchIntersect(myMap);
alert("Number of geo objects in the visible map area: " + result.getLength());
```

**4.**

```javascript
// Creating GeoQueryResult from vow.Deferred.
var result = ymaps.geoQuery(ymaps.geocode('Siromyatnicheskiy lane')).searchInside(myGeoBounds);
// Because the data source is asynchronous, we must wait for result processing.
result.then(function () {
    alert('Number of objects located inside the specified area: ' + result.getLength());
});
```

**5.**

```javascript
// Creating GeoQueryResult from JSON.
var result = ymaps.geoQuery({
    type: 'FeatureCollection',
    features: [
        {
            type: 'Feature',
            geometry: {
                type: 'Circle',
                coordinates: [15, 15],
                radius: 100
            }
        },
        {
            type: 'Feature',
            geometry: {
                type: 'LineString',
                coordinates: [[15, 16], [66, 23]]
            }
        },
        // Object collections can be nested.
        {
            type: 'FeatureCollection',
            features: [
                {
                    type: 'Feature',
                    geometry: {
                        type: 'Point',
                        coordinates: [12, 41]
                    },
                    properties: {
                        name: 'point'
                    },
                    options: {
                        preset: 'islands#yellowIcon'
                    }
                }
            ]
        }
    ]
});
// Adding non-point objects to the map as-is.
result.search('geometry.type != "Point"').addToMap(myMap);
// Adding point objects to the map via the clusterer.
myMap.geoObjects.add(result.search('geometry.type == "Point"').clusterize());
```
## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [add](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#add)([source](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#add-param-source)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Adds objects from the source to objects in the result. It does not change the source object; it creates a new object containing a combined set of geo objects. ||
|| [addEvents](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addEvents)([events](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addEvents-param-events), [callback](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addEvents-param-callback), [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addEvents-param-context)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Assigns event handlers to selection items. ||
|| [addTo](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addTo)([collection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addTo-param-collection)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for adding objects to a collection of geo objects. ||
|| [addToMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addToMap)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#addToMap-param-map)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for adding objects to the map. ||
|| [applyBoundsToMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#applyBoundsToMap)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#applyBoundsToMap-param-map)[, [options](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#applyBoundsToMap-param-options)]) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for setting the visible area of the map so that all the objects in the selection are visible. ||
|| [clusterize](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#clusterize)(\[[options](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#clusterize-param-options)]) | [Clusterer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Clusterer.md)
| This method creates a clusterer and adds objects from the selection to it. If the selection data are not ready yet, they will be added to the clusterer immediately after processing, and the returned clusterer will be empty at first. Only objects with the "Point" geometry will be added to the clusterer. ||
|| [each](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#each)([callback](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#each-param-callback), [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#each-param-context)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Returns self-reference. ||
|| [get](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#get)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#get-param-index)) | [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)
| Returns a selection item by index. ||
|| [getBounds](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getBounds)() | Number[][]\|null
| Returns geographical coordinates of the area that includes all the result objects. ||
|| [getCenter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getCenter)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getCenter-param-map)) | Number[]
| Method that returns the center of the area that covers all the result objects, in geographical coordinates. ||
|| [getCentralObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getCentralObject)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getCentralObject-param-map)) | [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)\|null
| Method for getting the object that is closest to the center of the visible area of the map. ||
|| [getClosestTo](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getClosestTo)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getClosestTo-param-object)) | [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)\|null
| Method that returns the selection object that is closest to the one specified. If an object that is already in the selection is given as input, it returns a different object from the selection that is closest to the one specified. Note that many of the geo objects must be added to the map for correct calculations. ||
|| [getExtreme](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getExtreme)([key](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getExtreme-param-key)) | Number
| Returns the maximum and minimum coordinate values among the coordinates of objects in the selection. ||
|| [getExtremeObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getExtremeObject)([key](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getExtremeObject-param-key)) | [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)
| Method that returns the object with the minimum or maximum coordinates among the coordinates of objects in the selection. ||
|| [getGlobalPixelBounds](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getGlobalPixelBounds)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getGlobalPixelBounds-param-map)) | Number[][]\|null
| Method that returns global pixel coordinates of the area for the current map zoom. ||
|| [getGlobalPixelCenter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getGlobalPixelCenter)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getGlobalPixelCenter-param-map)) | Number[]
| Returns coordinates of the center of the area, that covers all the result objects, in global pixel coordinates for the current map zoom. ||
|| [getIterator](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getIterator)() | [IIterator](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IIterator.md)
| Returns iterator for objects in the result. ||
|| [getLength](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getLength)() | Number
| Returns number of items in the result. ||
|| [getMaxZoom](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getMaxZoom)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getMaxZoom-param-map)[, [options](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getMaxZoom-param-options)]) | Number
| Method that calculates the maximum zoom level at which all the objects fall within the visible area of the map. ||
|| [getParent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#getParent)() | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)\|null
| Returns reference to the parent selection, if the current selection was created as the result of changing another GeoQueryResult object. ||
|| [indexOf](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#indexOf)([item](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#indexOf-param-item)) | Number
| Returns index of the item in the selection. If the item was not found, it returns -1. ||
|| [intersect](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#intersect)([result](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#intersect-param-result)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| This method creates a new selection containing common items for two different selections. ||
|| [isReady](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#isReady)() | Boolean
| Returns whether the selection results are ready or are still being processed. ||
|| [map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#map)([callback](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#map-param-callback)[, [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#map-param-context)]) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method that calls the "callback" method for all the selection items and forms a new selection based on the results received. ||
|| [remove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#remove)([objects](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#remove-param-objects)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Deletes objects from the result. It does not change the source object; it creates a new object containing the resulting set of geo objects. ||
|| [removeEvents](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeEvents)([events](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeEvents-param-events), [callback](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeEvents-param-callback), [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeEvents-param-context)) | | Deletes the subscription to events from an object. Note that in order to unsubscribe correctly, the arguments passed must be exactly the same as the ones for subscribing via the "addEvents" method. ||
|| [removeFrom](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeFrom)([collection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeFrom-param-collection)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for deleting objects from a collection. ||
|| [removeFromMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeFromMap)([map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#removeFromMap-param-map)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for deleting objects from the map. ||
|| [reverse](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#reverse)() | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Rearranges the selection items in reverse order and returns the new selection. ||
|| [search](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#search)([condition](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#search-param-condition)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for searching for selection objects that meet the conditions. ||
|| [searchContaining](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchContaining)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchContaining-param-object)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method that creates a new selection from objects containing the specified object. Note that many of the geo objects must be added to the map for correct calculations. ||
|| [searchInside](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchInside)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchInside-param-object)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method that creates a new selection from objects that are completely included in the specified object. Note that many of the geo objects must be added to the map for correct calculations. ||
|| [searchIntersect](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchIntersect)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchIntersect-param-object)[, [options](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#searchIntersect-param-options)]) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method that creates a new selection from objects intersecting the specified object. Note that many of the geo objects must be added to the map for correct calculations. ||
|| [setOptions](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setOptions)([key](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setOptions-param-key)[, [value](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setOptions-param-value)]) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for setting option values for all the selection items. ||
|| [setProperties](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setProperties)([path](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setProperties-param-path), [value](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#setProperties-param-value)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for setting the value of the "properties" field for all the selection items. ||
|| [slice](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#slice)([begin](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#slice-param-begin)[, [end](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#slice-param-end)]) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method that returns a slice of the selection. ||
|| [sort](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#sort)([comparator](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#sort-param-comparator)) | | Method for sorting selection objects. It does not change the original selection; it creates a new one containing sorted objects. ||
|| [sortByDistance](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#sortByDistance)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#sortByDistance-param-object)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for getting a selection containing objects sorted by their distance from the specified object. Note that many of the geo objects must be added to the map for correct calculations. It does not change the original selection. ||
|| [then](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#then)([[onFulfill](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#then-param-onFulfill)[, [onReject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#then-param-onReject), [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#then-param-context)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Subscription to the promise. ||
|| [unsetOptions](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#unsetOptions)([keys](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#unsetOptions-param-keys)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for nullifying option values for all the selection items. ||
|| [unsetProperties](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#unsetProperties)([path](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md#unsetProperties-param-path)) | [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)
| Method for nullifying the value of the "properties" field for all the selection items. ||
|#

## Methods details {#method_detail}

### add {#add}

```javascript
{GeoQueryResult} add(source)
```

Adds objects from the source to objects in the result. It does not change the source object; it creates a new object containing a combined set of geo objects.

**Returns** a new object with the combined set of geo objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`source`](#add-param-source)[*](*star) | — | Type: Object

Source of geo objects: 
- IGeoObject - Object that implements the corresponding interface.
- IGeoObject[] - Array of objects that implement the corresponding interface.
- ICollection - Collection of objects that implement the IGeoObject interface.
- ICollection[] - Array of object collections that implement the IGeoObject interface.
- vow.Promise - A promise object that passes the data source for geoQuery to the handler function. 	The handler function can also be passed an object with the geoObjects field containing the data source 	for geoQuery.
- GeoQueryResult - Object of the GeoQueryResult class.
- String\|Object - String or object with a JSON description of objects.
- Object[] - Array of JSON descriptions of geometries. An array item is an object with the 	"type" and "coordinates" fields. When describing a circle, the "radius" field is also mandatory. When describing a polygon, the optional "fillRule" field may also be specified.
JSON object descriptions are formed using the following approach (see the example below). An object may be an entity or a collection of entities. A collection of entities is made up of an object with the following fields: 
- type - Type of object. The value of the field must be "FeatureCollection".
- features - Array of child entities in the collection. Child objects may be entities or nested 	collections of entities.
An entity is made up of an object with the following fields: 
- type - Type of object. The value of the field must be "Feature".
- geometry - Object geometry. Contains the "type" and "coordinates" fields. Corresponds to the parameter 	passed to the constructor for the ymaps.GeoObject object.
- options - Options for the geo object.
- properties - Geo object data. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Adding a single geo object to GeoQueryResult.
var placemark = new ymaps.Placemark([34, 56]);
myGeoQueryResult.add(placemark);
```

**2.**

```javascript
// Adding an array of geo objects to GeoQueryResult.
var objects = [
    new ymaps.Placemark([34, 56]),
    new ymaps.Rectangle([[34, 56], [36, 57]])
];
// Note that a different GeoQueryResult object will be obtained in the result,
// while the old one remains unchanged.
var newResult = myGeoQueryResult.add(objects);
```

**3.**

```javascript
// Adding collections of geo objects to GeoQueryResult.
// Note that a different GeoQueryResult object will be obtained in the result,
// while the old one remains unchanged.
var newResult = myGeoQueryResult.add(myMap.geoObjects).searchIntersect(myBounds);
alert("Number of geo objects in the specified area: " + myGeoQueryResult.getLength());
```

**4.**

```javascript
// Adding geocoding results to GeoQueryResult.
// Note that a different GeoQueryResult will be obtained in the result,
// while the old one remains unchanged.
var newResult = myGeoQueryResult.add(ymaps.geocode('Siromyatnicheskiy lane'));
newResult.searchInside(myGeoBounds);
// Because the data source is asynchronous, we must wait for the result to be processed.
result.then(function () {
    // The source object still exists.
    alert('Before adding objects, the number of objects was:' + myGeoQueryResult.getLength());
    // The new object has both the old geo objects and the ones that were added.
    alert('After adding objects, the number of objects is: ' + result.getLength());
});
```

**5.**

```javascript
// Adding objects from a JSON string.
var result = ymaps.geoQuery(myMap.geoObjects);
var extendedResult = result.add('{"type": "Feature", "geometry": { "type": "Point", "coordinates": [15, 64] }}');
extendedResult.addToMap(myMap);
```
# addEvents

```javascript
{GeoQueryResult} addEvents(events, callback, context)
```

Assigns event handlers to selection items.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`events`](#addEvents-param-events)[*](*star) | — | Type: String\|String[]

Event type or array of event types that the subscription ends on. ||
|| [`callback`](#addEvents-param-callback)[*](*star) | — | Type: Function

Handler function. ||
|| [`context`](#addEvents-param-context)[*](*star) | — | Type: Object

Context for the handler function. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
ymaps.geoQuery(map.geoObjects).search('geometry.type="Circle"').addEvents('click', function () {
    alert('You clicked a circle!');
});
```
# addTo

```javascript
{GeoQueryResult} addTo(collection)
```

Method for adding objects to a collection of geo objects.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`collection`](#addTo-param-collection)[*](*star) | — | Type: [ICollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md)

The collection that objects will be added to. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Showing objects in the northern hemisphere on the map.
var result1 = ymaps.geoQuery(placemarks).search('lat > 0').addTo(myMap.geoObjects);
```

### addToMap {#addToMap}

```javascript
{GeoQueryResult} addToMap(map)
```

Method for adding objects to the map.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#addToMap-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map that objects will be added to. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Showing objects in the northern hemisphere on the map.
var result1 = ymaps.geoQuery(placemarks).search('lat > 0').addToMap(myMap);
```

### applyBoundsToMap {#applyBoundsToMap}

```javascript
{GeoQueryResult} applyBoundsToMap(map[, options])
```

Method for setting the visible area of the map so that all the objects in the selection are visible.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#applyBoundsToMap-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

Map. ||
|| [`options`](#applyBoundsToMap-param-options) | — | Type: Object

Options. ||
|| [`options.checkZoomRange`](#applyBoundsToMap-param-options.checkZoomRange) | false | Type: Boolean

Checks whether the specified zoom level can be set. If the value of this option is "true", the method is called asynchronously. A request is sent to the server, which returns the range of acceptable zoom values for the given center. After this, the specified center and appropriate zoom are applied. ||
|| [`options.duration`](#applyBoundsToMap-param-options.duration) | 0 | Type: Number

Animation duration, in milliseconds. ||
|| [`options.preciseZoom`](#applyBoundsToMap-param-options.preciseZoom) | false | Type: Boolean

The ability to use fractional zoom levels. ||
|| [`options.timingFunction`](#applyBoundsToMap-param-options.timingFunction) | 'linear' | Type: String

Timing function. The same as the value of the CSS property transition-timing-function. Full list of values: [http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag](http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag) ||
|| [`options.useMapMargin`](#applyBoundsToMap-param-options.useMapMargin) | true | Type: Boolean

Whether to account for map margins [map.margin.Manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.margin.Manager.md). ||
|| [`options.zoomMargin`](#applyBoundsToMap-param-options.zoomMargin) | 0 | Type: Number\|Number[]

Offset from the borders of the visible area of the map. If a single number is set, it is applied to each side. If two numbers are set, they are the horizontal and vertical margins, respectively. If an array of four numbers is set, they are the top, right, bottom, and left margins. When the "useMapMargin" option is enabled, the "zoomMargin" value is combined with the values that were calculated in the margins manager [map.margin.Manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.margin.Manager.md). ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Making a geocoding request and setting the visible area of the map
// so that all the results will be visible on it immediately.
var result = ymaps.geoQuery(ymaps.geocode('Lenin street')).applyBoundsToMap(myMap);
// Note that the request to the server is asynchronous and we need to wait for results.
result.then(function () {
    alert("Got results and adjusted the visible area of the map.");
}, function () {
    alert("An error occurred.");
});
```

**2.**

```javascript
// For synchronous requests, the new map area is set immediately.
var result = ymaps.geoQuery(objects).applyBoundsToMap(myMap);
alert('The visible area of the map changed.');
```

### clusterize {#clusterize}

```javascript
{Clusterer} clusterize([options])
```

This method creates a clusterer and adds objects from the selection to it. If the selection data are not ready yet, they will be added to the clusterer immediately after processing, and the returned clusterer will be empty at first. Only objects with the "Point" geometry will be added to the clusterer.

**Returns** clusterer.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`options`](#clusterize-param-options) | — | Type: Object

Options passed to the object constructor [Clusterer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Clusterer.md). ||
|#


**Example:**

```javascript
// Selecting only cafes and adding them to the clusterer.
var clusterer = ymaps.geoQuery(objects).search('properties.type="Cafe"').clusterize();
myMap.geoObjects.add(clusterer);
```

### each {#each}

```javascript
{GeoQueryResult} each(callback, context)
```

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`callback`](#each-param-callback)[*](*star) | — | Type: Function

Handler function. Called for each of the selection items and gets the item as input. ||
|| [`context`](#each-param-context)[*](*star) | — | Type: Object

Context for the handler function. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Hiding red placemarks in the visible area of the map.
ymaps.geoQuery(placemarks).searchIntersect(myMap).each(function(pm) {
    if (pm.options.get('preset') == 'islands#redIcon') {
        myMap.geoObjects.remove(pm);
    }
});
```

### get {#get}

```javascript
{IGeoObject} get(index)
```

**Returns** a selection item by index.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#get-param-index)[*](*star) | — | Type: Number

Index of items. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example with synchronous processing.
var result = ymaps.geoQuery(placemarks).sort('lat');
// The southernmost object.
var southObject = result.get(0);
// The northernmost object.
northObject = result.get(result.getLength() - 1);
```

**2.**

```javascript
// Example with asynchronous processing.
var result = ymaps.geoQuery(ymaps.geocode('Moscow cafe')).sort('lat');
// We have to wait for the result to be ready before processing further.
result.then(function () {
    // Southernmost object.
    var southObject = result.get(0);
    // Northermost object.
    var northObject = result.get(result.getLength() - 1);
});
```

### getBounds {#getBounds}

```javascript
{Number[][]|null} getBounds()
```

**Returns** geographical coordinates of the area that includes all the result objects.

**Examples:**

**1.**

```javascript
// Example of adding the objects synchronously.
// Setting the map center and zoom so that all the objects added to the map are displayed.
var myResult = ymaps.geoQuery(myMap.geoObjects);
myMap.setBounds(myResult.getBounds(), { checkZoomRange: true });
```

**2.**

```javascript
// Example of adding the objects asynchronously.
// Waiting for the data and only then call the getBounds method.
var myResult = ymaps.geoQuery(ymaps.geocode(' Zveronozhka river')).then(function () {
     myMap.setBounds(myResult.getBounds(), { checkZoomRange: true });
});
```

### getCenter {#getCenter}

```javascript
{Number[]} getCenter(map)
```

Method that returns the center of the area that covers all the result objects, in geographical coordinates.

**Returns** coordinates of the center of the area, in geographical coordinates.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#getCenter-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map to make calculations for. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Moving the map center to the center of the area that covers the objects.
myMap.setCenter(ymaps.geoQuery(objects).getCenter());
```

### getCentralObject {#getCentralObject}

```javascript
{IGeoObject|null} getCentralObject(map)
```

Method for getting the object that is closest to the center of the visible area of the map.

**Returns** reference to a geo object, or null if the selection is empty.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#getCentralObject-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

Map. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example of working with synchronous operations.
// Opening a balloon at the object closest to the center of the visible area of the map.
ymaps.geoQuery(objects).getCentralObject(myMap).balloon.open();
```

**2.**

```javascript
// Usage example with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Ulitsa Stroiteley'));
// We just sent the geocoding request so we need to wait for
// the result.
result.then(function () {
    result.getCentralObject(myMap).balloon.open();
});
```

### getClosestTo {#getClosestTo}

```javascript
{IGeoObject|null} getClosestTo(object)
```

Method that returns the selection object that is closest to the one specified. If an object that is already in the selection is given as input, it returns a different object from the selection that is closest to the one specified. Note that many of the geo objects must be added to the map for correct calculations.

**Returns** the selection object closest to the one specified, or null if the object cannot be found.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#getClosestTo-param-object)[*](*star) | — | Type: Object

The object that the search will be relative to. Accepts the following values: 
- IGeoObject - Object that implements the [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) interface.
- IGeometry - Object that implements the [IGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometry.md) interface.
- Map - The map. In this case, the reference object is the rectangular border of the map.
- Number[] - Coordinates of a point.
- Object - JSON description of a geometry. Contains the "type" and "coordinates" fields. When describing a circle, the "radius" field is also mandatory. When describing a polygon, 	the optional "fillRule" field may also be specified. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Examples of using the method with various input data.
var result = ymaps.geoQuery(objects).addToMap(myMap);

// 1. IGeoObject.
// A search can be made relative to an outside object.
var polyline = new ymaps.Polyline([[35, 65], [35, 66], [34, 62], [34, 63]]);
myMap.geoObjects.add(polyline);
var closestObject = result.getClosestTo(polyline);
// The search can be based on an object from the same selection.
var closestToFirst = result.getClosestTo(result.get(0));

// 2. IGeometry.
var closestToGeometry = result.getClosestTo(placemark.geometry);

// 3. Map.
// Finding the object closest to the border of the visible area of the map.
var edgeObject = result.getClosestTo(myMap);

// 4. Object nearest a point.
var closestObject = result.getClosestTo([34, 53]);
```

**2.**

```javascript
// Example with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Paris')).addToMap(myMap);
// Waiting for the server response and getting the object nearest the point.
result.then(function () {
    var closestObject = result.getClosestTo([34, 65]);
    // If the response is empty, the nearest object will not be found.
    if (closestObject) {
        closestObject.balloon.open();
    }
});
```

### getExtreme {#getExtreme}

```javascript
{Number} getExtreme(key)
```

**Returns** the maximum and minimum coordinate values among the coordinates of objects in the selection.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`key`](#getExtreme-param-key)[*](*star) | — | Type: String

Key for receiving data. Accepts the following values: 
- top
- right
- bottom
- left ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example with synchronous operations.
alert('Northernmost coordinate: ', ymaps.geoQuery(myMap.geoObjects).getExtreme('top'));
```

**2.**

```javascript
// Example with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Novgorod'));
// Waiting for the server response and getting the northernmost coordinate.
result.then(function () {
    alert('Northernmost coordinate in the response: ' + result.getExtreme('top'));
});
```

### getExtremeObject  {#getExtremeObject}

```javascript
{IGeoObject} getExtremeObject(key)
```

Method that returns the object with the minimum or maximum coordinates among the coordinates of objects in the selection.

**Returns** object with the required coordinate.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`key`](#getExtremeObject-param-key)[*](*star) | — | Type: String

Key for searching for an object. Accepts the following values: 
- top
- right
- bottom
- left ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example with synchronous operations.
// Opening a balloon on the northernmost object.
var topObject = ymaps.geoQuery(myMap.geoObjects).getExtremeObject('top');
topObject.balloon.open();
```

**2.**

```javascript
// Example with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Laptev Sea'));
// Waiting for the server response in order to work with data.
result.then(function () {
    var topObject = result.getExtremeObject('top');
    // If the response is empty, the object will not be found.
    if (topObject) {
        topObject.balloon.open();
    }
});
```

### getGlobalPixelBounds {#getGlobalPixelBounds}

```javascript
{Number[][]|null} getGlobalPixelBounds(map)
```

Method that returns global pixel coordinates of the area for the current map zoom.

**Returns** global pixel coordinates of the area that includes all objects in the result.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#getGlobalPixelBounds-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map that calculations are being made for. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var result = ymaps.geoQuery(placemarks).search('properties.type="shop"').getGlobalPixelBounds(myMap);
if (Math.abs(result[0][0] - result[1][0]) > myMap.container.getSize()[0]) {
   alert('Objects are too wide to fit on the map!');
}
```

### getGlobalPixelCenter {#getGlobalPixelCenter}

```javascript
{Number[]} getGlobalPixelCenter(map)
```

**Returns** coordinates of the center of the area, that covers all the result objects, in global pixel coordinates for the current map zoom.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#getGlobalPixelCenter-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map to make calculations for. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Calculating the tile number that contains the center of the area that spans the result.
var globalPixelCenter = ymaps.geoQuery(objects).getGlobalPixelCenter(myMap);
var tileNumber = [
    Math.floor(globalPixelCenter[0] / 256),
    Math.floor(globalPixelCenter[1] / 256)
];
alert('Number of the center tile: ' + tileNumber[0] + ' ' + tileNumber[1]);
```

### getIterator {#getIterator}

```javascript
{IIterator} getIterator()
```

**Returns** iterator for objects in the result.

**Examples:**

**1.**

```javascript
// Using the iterator with synchronous operations.
// Searching for elements that match the click coordinates.
myMap.events.add('click', function (event) {
    var iterator = ymaps.geoQuery(myMap.geoObjects)
        .searchContaining(event.getCoordinates())
        .getIterator();
    var   obj;
    while ((obj = iterator.getNext()) != iterator.STOP_ITERATION) {
        // Performing the necessary actions on a geo object.
    }
});
```

**2.**

```javascript
// Using an iterator with asynchronous operations.
// Creating a result from the geocoder query.
var result = ymaps.geoQuery(ymaps.geocode("Starokolpakskiy street")).search("lat > 20");
// Note that we only sent the request to the server, and the response will come later.
// Because the request is asynchronous, we need to wait for it to be ready before getting the result.
result.then(function () {
    var iterator = result.getIterator();
    var obj;
    while ((obj = iterator.getNext())  != iterator.STOP_ITERATION) {
        // Performing the necessary actions on the geo object.
    }
});
```

### getLength {#getLength}

```javascript
{Number} getLength()
```

**Returns** number of items in the result.

**Examples:**

**1.**

```javascript
var result = ymaps.geoQuery(myMap.geoObject).searchIntersect(myPolygon);
alert('The number of geo objects that intersect with the polygon: ' + result.getLength());
```

**2.**

```javascript
var result = ymaps.geoQuery(ymaps.geocode('Ivanovo')).searchInside(myMap);
// Because we sent the request to the server, we cannot immediately count
// the number of elements in the result. We have to wait for the response.
result.then(function () {
    alert('Number of objects in the visible area of the map: ' + result.getLength());
});
```

### getMaxZoom {#getMaxZoom}

```javascript
{Number} getMaxZoom(map[, options])
```

Method that calculates the maximum zoom level at which all the objects fall within the visible area of the map.

**Returns** maximum map zoom level.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#getMaxZoom-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map that the calculation is being made for. ||
|| [`options`](#getMaxZoom-param-options) | — | Type: Object

Options. ||
|| [`options.useMapMargin`](#getMaxZoom-param-options.useMapMargin) | true | Type: Boolean

Whether to account for map margins [map.margin.Manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.margin.Manager.md). ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Calculating the maximum zoom level
// at which all the selection objects are visible
// and setting a restriction for the map.
var maxZoom = ymaps.geoQuery(objects).getMaxZoom();
myMap.options.set('maxZoom', maxZoom);
```

### getParent {#getParent}

```javascript
{GeoQueryResult|null} getParent()
```

**Returns** reference to the parent selection, if the current selection was created as the result of changing another GeoQueryResult object.

**Example:**

```javascript
ymaps.geoQuery(objectsArray)
    // Selecting only objects of the type "cafe" and defining their styles.
    .search('properties.type == "cafe"')
    .setOptions('preset', 'islands#yellowDotIcon')
    // Then, without interrupting the chain of calls,
    // getting back to the original selection and defining styles for another group of objects.
    .getParent()
    .search('properties.type == "shop"')
    .setOptions('preset', 'islands#greenDotIcon');
```

### indexOf {#indexOf}

```javascript
{Number} indexOf(item)
```

**Returns** index of the item in the selection. If the item was not found, it returns -1.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`item`](#indexOf-param-item)[*](*star) | — | Type: [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

The required object. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Sorting the selection by the "name" field.
var result = ymaps.geoQuery(polygons).sort('properties.name');
alert('New position of the first item: ' + result.indexOf(polygons[0]));
```

### intersect {#intersect}

```javascript
{GeoQueryResult} intersect(result)
```

This method creates a new selection containing common items for two different selections.

**Returns** the new selection that contains the intersection result.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`result`](#intersect-param-result)[*](*star) | — | Type: [GeoQueryResult](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoQueryResult.md)

The selection to intersect the first one with. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example of intersection with synchronous operations.
var result = ymaps.geoQuery(placemarks);
var greenObjects = result.search('properties.color="green"');
var roundObjects = result.search('properties.shape="round"');
var greenRoundObjects = greenObjects.intersect(roundObjects);
alert('Number of round green objects: ' + greenRoundObjects.getLength());
```

**2.**

```javascript
// Example of intersection with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Ivanovka'));
var filteredByLat = result.search('lat > 56');
var filteredByLong = result.search('long > 36');
var intersectedResult = filteredByLat.intersect(filteredByLong);
// Because the original request is asynchronous, we must wait for data to be ready.
intersectedResult.then(function () {
    alert('Number of objects with the name "Ivanovka" +
        'with coordinates higher than [56, 36]: ' +
        intersectedResult.getLength());
});
```
# isReady

```javascript
{Boolean} isReady()
```

**Returns** whether the selection results are ready or are still being processed.

**Example:**

```javascript
var result = ymaps.geoQuery(ymaps.geocode('Ivanovo'));
if (!result.isReady()) {
    result.then(function () {
        // Processing data.
    });
} else {
    // Processing data.
}
```

### map {#map}

```javascript
{GeoQueryResult} map(callback[, context])
```

Method that calls the "callback" method for all the selection items and forms a new selection based on the results received.

**Returns** the new selection.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`callback`](#map-param-callback)[*](*star) | — | Type: Function

Handler function. Takes a selection item as input. Returns an instance of [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md). ||
|| [`context`](#map-param-context) | — | Type: Object

Context for the handler function. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Adding only circle objects to the map.
var circlesResult = ymaps.geoQuery(objects).search('geometry.type="Circle"').addToMap(myMap);
// We'll also add placemarks that indicate the circle centers.
var centers = circlesResult.map(function (object) {
    return new ymaps.Placemark(object.geometry.getCenter());
}).addToMap(myMap);
```

### remove {#remove}

```javascript
{GeoQueryResult} remove(objects)
```

Deletes objects from the result. It does not change the source object; it creates a new object containing the resulting set of geo objects.

**Returns** new object with the resulting set of geo objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`objects`](#remove-param-objects)[*](*star) | — | Type: Object

Objects can be presented in various forms: 
- IGeoObject - Object that implements the corresponding interface.
- IGeoObject[] - Array of objects that implement the corresponding interface.
- ICollection - Collection of objects that implement the IGeoObject interface.
- ICollection[] - Array of object collections that implement the IGeoObject interface.
- GeoQueryResult - Object of the GeoQueryResult class. Note that with asynchronous operations, 	the result has to be prepared before it can be deleted correctly.
- vow.Promise - Object of the vow.Deferred class. Must be resolved by an array of geo objects or 	an object with the "geoObjects" field. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
var objects = [
    new ymaps.Placemark([34, 56]),
    new ymaps.Rectangle([[34, 56], [36, 57]])
];
var result = ymaps.geoQuery(objects);
// Note that a different GeoQueryResult object will be obtained in the result,
// while the old one remains unchanged.
var newResult = result.remove(objects[1]);
```

**2.**

```javascript
// Deleting an array of geo objects from GeoQueryResult.
var objects = [
    new ymaps.Placemark([34, 56]),
    new ymaps.Rectangle([[34, 56], [36, 57]]),
    new ymaps.Placemark([35, 64])
];
var result = ymaps.geoQuery(objects);
// Note that a different GeoQueryResult object will be obtained in the result,
// while the old one remains unchanged.
var newResult = result.remove([objects[1], objects[2]]);
```

**3.**

```javascript
// Deleting collections of geo objects from GeoQueryResult.
// Adding objects to the map that aren't on it yet.
myGeoQueryResult.remove(myMap.geoObjects).addToMap(myMap);
```

**4.**

```javascript
// Deleting data of a different GeoQueryResult from GeoQueryResult.
var result1 = ymaps.geoQuery(placemarks).search('properties.color="green"');
var result2 = ymaps.geoQuery(placemarks).search('properties.shape="circle"');
var result3 = result1.remove(result2);
alert('Number of green non-round shapes: ' + result3.getLength());
```
# removeEvents

```javascript
{} removeEvents(events, callback, context)
```

Deletes the subscription to events from an object. Note that in order to unsubscribe correctly, the arguments passed must be exactly the same as the ones for subscribing via the "addEvents" method.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`events`](#removeEvents-param-events)[*](*star) | — | Type: String\|String[]

Event type or array of types that a subscription was made to. ||
|| [`callback`](#removeEvents-param-callback)[*](*star) | — | Type: Function

Handler function that was specified when subscribing. ||
|| [`context`](#removeEvents-param-context)[*](*star) | — | Type: Object

Context that was specified when subscribing. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var callback = function () {
    alert('You clicked a circle!');
};
ymaps.geoQuery(map.geoObjects).search('geometry.type="Circle"').addEvents('click', callback);
// ...
ymaps.geoQuery(map.geoObjects).search('geometry.type="Circle"').removeEvents('click', callback);
```
# removeFrom

```javascript
{GeoQueryResult} removeFrom(collection)
```

Method for deleting objects from a collection.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`collection`](#removeFrom-param-collection)[*](*star) | — | Type: [ICollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md)

The collection to delete objects from. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Showing all objects on the map.
var result1 = ymaps.geoQuery(placemarks).addTo(myMap.geoObjects);
// Then hiding objects in the northern hemisphere.
var result2 = result1.search('lat > 0').removeFrom(myMap.geoObjects);
```

### removeFromMap {#removeFromMap}

```javascript
{GeoQueryResult} removeFromMap(map)
```

Method for deleting objects from the map.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`map`](#removeFromMap-param-map)[*](*star) | — | Type: [Map](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md)

The map to delete objects from. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Showing all objects on the map.
var result1 = ymaps.geoQuery(placemarks).addToMap(myMap);
// Then hiding objects in the northern hemisphere.
var result2 = result1.search('lat > 0').removeFromMap(myMap);
```

### reverse {#reverse}

```javascript
{GeoQueryResult} reverse()
```

Rearranges the selection items in reverse order and returns the new selection.

**Returns** the new selection with items in reverse order.

**Examples:**

**1.**

```javascript
// Usage with synchronous requests.
var result = ymaps.geoQuery(myMap.geoObjects).sort('x'),
    invertedResult = result.reverse();
```

**2.**

```javascript
// Usage with asynchronous requests.
var result = ymaps.geoQuery(ymaps.geocode('Friendly Bees village')).sort('x');
var invertedResult = result.reverse();
invertedResult.then(function () {
    // Got the result. Ready to use.
});
```

### search {#search}

```javascript
{GeoQueryResult} search(condition)
```

Method for searching for selection objects that meet the conditions.

**Returns** a new selection containing search results.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`condition`](#search-param-condition)[*](*star) | — | Type: String\|Function

String template for search or a filter function. A string template has the structure "\<fieldname> \<condition> \<expression>". Acceptable values for \<fieldname>: 
- 'lat' - Latitude. Supported only for point objects.
- 'lng', 'long' - Longitude. Supported only for point objects.
- 'x' - Global pixel coordinates on the X axis. Supported only for point objects.
- 'y' - Global pixel coordinates on the Y axis. Supported only for point objects.
- 'geometry.type' - Type of geometry. Result of executing the geometry.getType() method.
- 'geometry.coordinates.\<index>' - Coordinates. Result of executing the geometry.getCoordinates() method. To get access to a coordinate, specify its indexes after a dot - 'geometry.coordinates.0.1'.
- 'properties.\<path>' - Value of the data field.
- 'options.\<key>' - Value of options.
Acceptable values for \<condition>: 
- '>'
- '>='
- '==', '='
- '!='
- '<='
- '<'
- 'rlike', 'regexp' - Matches the \<fieldname> value to a regular expression.
Acceptable values for \<expression>: 
- Number
- String (must be put in quotation marks)
- true
- false
- null
- undefined
The filter function takes a selection object as input and returns true/false. True means the object is in the resulting selection, and false means it is not. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Example of searching for objects with synchronous operations.
var result = ymaps.geoQuery(myMap.geoObjects);

         // Searching for objects with a specific type of geometry. Note that
// the field value shown in quotes is a string.
result.search('geometry.type = "Circle"')
// Searching by a coordinate.
    .search('geometry.coordinates.0 > 100')
// Searching by latitude.
    .search('lat < 0')
// Searching by pixel coordinates.
    .search('x >= 100')
// Searching by the field value in "properties".
    .search('properties.name != null').search('properties.name rlike "(.) \\""')
    .search('properties.author.name = "Stepan"')
// Searching by option value.
    .search('options.visible = true');
```

**2.**

```javascript
// Using the method with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Moose'));
// Waiting for the result to be ready before working with it.
result.then(function () {
    result.search('properties.description regExp "*village*"')
        .addToMap(myMap)
        .applyBoundsToMap(myMap);
});
```

### searchContaining {#searchContaining}

```javascript
{GeoQueryResult} searchContaining(object)
```

Method that creates a new selection from objects containing the specified object. Note that many of the geo objects must be added to the map for correct calculations.

**Returns** a new selection containing the desired objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#searchContaining-param-object)[*](*star) | — | Type: Object

The object that the search will be relative to. Accepts the following values: 
- IGeoObject - Object that implements the [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) interface.
- IGeometry - Object that implements the [IGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometry.md) interface.
- Map - The map. In this case, the reference object is the rectangular border of the map.
- Number[] - Coordinates of a point. If one parameter is passed, it is interpreted as a point. If two arguments are passed, it is interpreted as a circle.
- Number[][] - Coordinates of a rectangular area.
- Object - JSON descriptions of a geometry. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Examples of using the method with various input data.
var result = ymaps.geoQuery(objects).addToMap(myMap);

// 1. IGeoObject.
var polygon = new ymaps.Polygon([[[35, 65], [35, 66], [34, 62], [34, 63], [35, 65]]]);
myMap.geoObjects.add(polygon);
var objectsContainingPolygon = result.searchContaining(polygon);

// 2. IGeometry.
var objectsContainingGeometry = result.searchContaining(polygon.geometry);

// 3. Map.
var objectsContainingMapBounds = result.searchContaining(myMap);
```

**2.**

```javascript
// Example of usage with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('cafe'))
        .addToMap(myMap);
// Waiting for the server response before processing results.
result.then(function () {
    var areas = result.map(function (object) {
        return new ymaps.Circle(object.geometry.getCoordinates(), 100);
    })
        .setOptions('visible', false)
        .addToMap(myMap);
    myMap.events.add('click', function (event) {
        if (areas.searchContaining(event.getCoordinates()).getLength()) {
            alert('You clicked near a cafe.');
        }
    });
});
```
# searchInside

```javascript
{GeoQueryResult} searchInside(object)
```

Method that creates a new selection from objects that are completely included in the specified object. Note that many of the geo objects must be added to the map for correct calculations.

**Returns** a new selection containing the desired objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#searchInside-param-object)[*](*star) | — | Type: Object

The object that the search will be relative to. Accepts the following values: 
- IGeoObject - Object that implements the [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) interface.
- IGeometry - Object that implements the [IGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometry.md) interface.
- Map - The map. In this case, the reference object is the rectangular border of the map. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Examples of using the method with various input data.
var result = ymaps.geoQuery(objects).addToMap(myMap);

// 1. IGeoObject.
var polygon = new ymaps.Polygon([[[35, 65], [35, 66], [34, 62], [34, 63], [35, 65]]]);
myMap.geoObjects.add(polygon);
var objectsInsidePolygon = result.searchInside(polygon);

// 2. IGeometry.
var objectsInsideGeometry = result.searchInside(polygon.geometry);

// 3. Map.
// We'll find objects that fit entirely inside the visible area of the map.
var visibleObject = result.searchInside(myMap);
```

**2.**

```javascript
// Example of usage with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Ivanovo'))
        .setOptions('visible', false)
        .addToMap(myMap);
// Waiting for the server response and then showing objects that fit inside the visible area of the map.
result.then(function () {
    result.searchInside(myMap).setOptions('visible', true);
});
```

### searchIntersect {#searchIntersect}

```javascript
{GeoQueryResult} searchIntersect(object[, options])
```

Method that creates a new selection from objects intersecting the specified object. Note that many of the geo objects must be added to the map for correct calculations.

**Returns** a new selection containing the desired objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#searchIntersect-param-object)[*](*star) | — | Type: Object

The object that the search will be relative to. Accepts the following values: 
- IGeoObject - Object that implements the [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) interface.
- IGeometry - Object that implements the [IGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometry.md) interface.
- Map - The map. In this case, the reference object is the rectangular border of the map. ||
|| [`options`](#searchIntersect-param-options) | — | Type: Object

Options. ||
|| [`options.considerOccurance`](#searchIntersect-param-options.considerOccurance) | true | Type: Object

Flag indicating whether we consider it an intersection when one figure is completely contained inside another. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Examples of using the method with various input data.
var result = ymaps.geoQuery(objects).addToMap(myMap);

// 1. IGeoObject.
var polygon = new ymaps.Polygon([[[35, 65], [35, 66], [34, 62], [34, 63], [35, 65]]]);
myMap.geoObjects.add(polygon);
var objectsIntersectPolygon = result.searchIntersect(polygon);

// 2. IGeometry.
var objectsIntersectGeometry = result.searchIntersect(polygon.geometry);

// 3. Map.
// We will only search for objects that directly intersect
// the map border. In other words, objects that are entirely inside the visible area of the map
// will not be in the final selection.
var objectsIntersectMapBounds = result.searchIntersect(myMap, {considerOccurance: false});
```

**2.**

```javascript
// Example of usage with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('cafe'))
        .setOptions('visible', false)
        .addToMap(myMap);

// Waiting for the server response and then showing objects that fall within the map viewport.
result.then(function () {
    result.searchIntersect(myMap).setOptions('visible', true);
});
```
# setOptions

```javascript
{GeoQueryResult} setOptions(key[, value])
```

Method for setting option values for all the selection items.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`key`](#setOptions-param-key)[*](*star) | — | Type: String\|Object

Option name or hash with options and their values. ||
|| [`value`](#setOptions-param-value) | — | Type: Object

Option value. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var result = ymaps.geoQuery(placemarks);
// Making elements visible if they fall within a rectangular area.
result.searchIntersect(myBounds).setOptions('visible', true);

// Setting options using a hash.
result.setOptions({zIndex: 10, fillColor: '#ff0005'});
```

### setProperties {#setProperties}

```javascript
{GeoQueryResult} setProperties(path, value)
```

Method for setting the value of the "properties" field for all the selection items.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`path`](#setProperties-param-path)[*](*star) | — | Type: String

Name of the field that the value is assigned to. It may contain ".". ||
|| [`value`](#setProperties-param-value)[*](*star) | — | Type: Object

Field value. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var result = ymaps.geoQuery(objects);
// Marking elements that fall inside the area.
result.searchIntersect(myBounds1).setProperties('intersectBounds', true);
result.searchIntersect(myBounds2).setProperties('intersectBounds', true);
// ...
result.search('properties.intersectBounds = true').addToMap(myMap);
```
# slice

```javascript
{GeoQueryResult} slice(begin[, end])
```

Method that returns a slice of the selection.

**Returns** the new selection containing items in the slice.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`begin`](#slice-param-begin)[*](*star) | — | Type: Number

Index of the first item in the slice. ||
|| [`end`](#slice-param-end) | — | Type: Number

Index of the selection item that ends the slice. However, the last item in the new slice will be the item with the index end-1. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Making a slice with asynchronous processing.
var result = ymaps.geoQuery(map.geoObjects).slice(0, 10);
alert('Number of items in new selection:' + result.getLength());
```

**2.**

```javascript
// Getting a slice with asynchronous processing.
var result = ymaps.geoQuery(ymaps.geocode('cafe Moscow')).slice(0, 10);
// The result is not ready immediately after the request.
alert('The selection is still empty. Number of items in selection: ' + result.getLength());
// Waiting for the result to be ready and then we will see how many items will be in the selection.
result.then(function () {
    alert('Response received. Amount of data in the selection: ' + result.getLength());
});
```

### sort {#sort}

```javascript
{} sort(comparator)
```

Method for sorting selection objects. It does not change the original selection; it creates a new one containing sorted objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`comparator`](#sort-param-comparator)[*](*star) | — | Type: String|Function

String with a sorting template or a compare function. The template string can be in the format '\<fieldname> [<order>=asc]'. Acceptable values for \<fieldname>: 
- 'lat' - Latitude. Supported only for point objects.
- 'lng', 'long' - Longitude. Supported only for point objects.
- 'x' - Global pixel coordinates on the X axis. Supported only for point objects.
- 'y' - Global pixel coordinates on the Y axis. Supported only for point objects.
- 'geometry.type' - Type of geometry. Result of executing the geometry.getType() method.
- 'geometry.coordinates.\<index>' - Coordinates. Result of executing the geometry.getCoordinates() method. To get access to a coordinate, specify its indexes after a dot - 'geometry.coordinates.0.1'.
- 'properties.\<path>' - Value of the data field.
- 'options.\<key>' - Value of options.
Acceptable values for the optional \<order>: parameter: 
- 'asc' - Sort in ascending order.
- 'desc' - Sort in descending order.
The compare function takes two selection items as input. Returned values: If the first object is larger than the second, the function returns the value > 0. If the first object is equal to the second, the function returns 0. If the first object is smaller than the second, the function returns < 0. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Example with synchronous operations.
var result = ymaps.geoQuery(myMap.geoObjects);
result.sort('lat').sort('x')
    .sort('properties.name desc')
    .sort('options.preset')
    .sort(function (a, b) {
        if (a.properties.get('name') == b.properties.get('name')) {
            return a.geometry.getCoordinates()[0] - b.geometry.getCoordinates()[0];
        } else {
            return (a.properties.get('name') > b.properties.get('name')) ? 1 : -1;
        }
    });
```

### sortByDistance {#sortByDistance}

```javascript
{GeoQueryResult} sortByDistance(object)
```

Method for getting a selection containing objects sorted by their distance from the specified object. Note that many of the geo objects must be added to the map for correct calculations. It does not change the original selection.

**Returns** the new ordered selection.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#sortByDistance-param-object)[*](*star) | — | Type: Object

The object that the distance will be calculated to. Accepts the following values: 
- IGeoObject - Object that implements the [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) interface.
- IGeometry - Object that implements the [IGeometry](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometry.md) interface.
- Map - The map. In this case, the reference object is the rectangular border of the map.
- Number[] - Coordinates of a point.
- Number[][] - Coordinates of a rectangular area.
- Object - JSON description of a geometry. Contains the "type" and "coordinates" fields. When describing a circle, the "radius" field is also mandatory. When describing a polygon, 	the optional "fillRule" field may also be specified. ||
|#

\* Mandatory parameter/option.

**Examples:**

**1.**

```javascript
// Examples of using the method with various input data.
var result = ymaps.geoQuery(objects).addToMap(myMap);

// 1. IGeoObject.
var polyline = new ymaps.Polyline([[35, 65], [35, 66], [34, 62], [34, 63]]);
myMap.geoObjects.add(polyline);
var sortedByPolyline = result.sortByDistance(polyline);

// 2. IGeometry.
var sortedByGeometry = result.sortByDistance(placemark.geometry);

// 3. Map.
var sortedByMapBounds = result.sortByDistance(myMap);

// 4. The selection sorted by a point.
var sortedByPoint = result.sortByDistance([34, 53]);
```

**2.**

```javascript
// Example with asynchronous operations.
var result = ymaps.geoQuery(ymaps.geocode('Paris')).addToMap(myMap).sortByDistance([45, 64]);
// Waiting for the result from the server and getting the nearest and furthest
// object relative to the point.
result.then(function () {
    alert('The nearest object has the coordinates ' + result.get(0).geometry.getCoordinates());
    alert('The furthest object has the coordinates ' + result.get(result.getLength() - 1).geometry.getCoordinates());
});
```

### then {#then}

```javascript
{GeoQueryResult} then([onFulfill[, onReject, context)
```

Subscription to the promise.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`onFulfill`](#then-param-onFulfill) | — | Type: Function

Handler function that is called if the promise was fulfilled. ||
|| [`onReject`](#then-param-onReject) | — | Type: Function

Handler function that is called if the promise was not fulfilled (an error occurred). ||
|| [`context`](#then-param-context)[*](*star) | — | Type: Object

Context for the handler function. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var result = ymaps.geoQuery(ymaps.geocode('Lena river'));
result.then(function () {
    alert('Number of objects found: ' + result.getLength());
}, function () {
    alert('Error occurred.');
});
```
# unsetOptions

```javascript
{GeoQueryResult} unsetOptions(keys)
```

Method for nullifying option values for all the selection items.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`keys`](#unsetOptions-param-keys)[*](*star) | — | Type: String\|String

Name or array of names of options that should be canceled. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
result.unsetOptions('visible');
```

### unsetProperties {#unsetProperties}

```javascript
{GeoQueryResult} unsetProperties(path)
```

Method for nullifying the value of the "properties" field for all the selection items.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`path`](#unsetProperties-param-path)[*](*star) | — | Type: String

Name of a field to cancel the value for. It may contain ".". ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
var result = ymaps.geoQuery(objects);
// Marking items that fall inside the first area, but do not fall inside the second one.
result.searchIntersect(myBounds1).setProperties('intersectBounds', true);
result.searchIntersect(myBounds2).unsetProperties('intersectBounds', true);
// ...
result.search('properties.intersectBounds = true').addToMap(myMap);
```

[*star]: Mandatory parameter/option.