geoQuery
Static function.
Forms a data set from the specified source and creates an instance of GeoQueryResult based on it.
Returns result containing data from the source.
{ GeoQueryResult } geoQuery(source)
Parameters:
Parameter |
Default value |
Description |
— |
Type: Object Source of geo objects:
|
* Mandatory parameter/option.
Examples:
1.
// Creating GeoQueryResult from a single geo object.
var placemark = new ymaps.Placemark([34, 56]);
ymaps.geoQuery(placemark).addToMap(myMap);
2.
// 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.
// 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.
// 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.
// 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]]
}
},
{
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());
Mandatory parameter/option.