UNPKG

@yandex/ymaps3-types

Version:

Types for ymaps3 maps library

97 lines (96 loc) 3.31 kB
import type { LngLat, LngLatBounds } from "../../common/types"; import { Config } from "../config"; export type SearchType = "businesses" | "toponyms"; export type SearchOptions = { /** Request string represented by a text or {@link LngLat LngLat} point. */ text?: string; /** * Additional information about the object. * The parameter value is returned in the Geosuggest response. * To use it in a request, specify a value instead of text. */ uri?: string; /** * {@link type `type`} parameter specifies the type of * objects that are being searched (and the order of objects * if both types are queried): * - toponyms * - businesses **/ type?: SearchType[]; /** * @deprecated * Map zoom. **/ zoom?: number; /** * Flag that defines whether * search area is restricted by the provided parameters. * * Area restriction is specified by {@link SearchOptions.center `center`} * and {@link SearchOptions.span `span`} parameters * or {@link SearchOptions.bounds `bounds`} parameter. * * false — the search area is *not* restricted * * true — the search area is restricted **/ strictBounds?: boolean; /** * The maximum amount of returned objects. * * Parameter has to be specified explicitly if {@link SearchOptions.offset `offset`} parameter is provided. * * **10** is default. * * **100** is maximum. **/ limit?: number; /** * The amount of objects (if any returned) that are skipped starting from the first one. * * Parameter {@link SearchOptions.limit `limit`} must be provided. **/ offset?: number; /** * {@link LngLat `LngLat`} of the center point of search area. * * {@link SearchOptions.span `span`} parameter sets the length of the search area. **/ center?: LngLat; /** * Parameter {@link span `span`} is specified with two numbers that represent * differences between the minimum and maximum: * - longitude of the area * - latitude of the area */ span?: LngLat; /** * {@link bounds `bounds`} parameter has priority over * {@link SearchOptions.center `center`} and {@link SearchOptions.spn `span`} **/ bounds?: LngLatBounds; }; export type Feature = { properties: { name: string; description: string; }; geometry?: { type: "Point"; coordinates: LngLat; }; }; export type SearchResponse = Feature[]; /** * Static function to work with Search API. * * Before using this function it is required to set apikey for Search API * using `ymaps3.getDefaultConfig().setApikeys({search: "YOUR_SEARCH_API_KEY"})`. * You can get the key in the [Developer's Dashboard](https://developer.tech.yandex.ru/services). * * * @param {SearchOptions} options Request options * @param {Config} config Current config * @returns {Promise<SearchResponse>} */ export declare function search(options: SearchOptions, config?: Config | undefined): Promise<SearchResponse>;