@yandex/ymaps3-types
Version:
Types for ymaps3 maps library
85 lines (84 loc) • 2.82 kB
TypeScript
import type { DrawingStyle, GenericGeometry, LngLat, HideOutsideRule } from "../../common/types";
import type { BlockingProps, DraggableProps, FeatureClickEvents } from "./types";
import { YMapEntity } from "../YMapEnities";
import type { Geometry, YMapFeatureEventHandler } from "./types";
/**
* YMapFeature props
*/
type YMapFeatureProps = {
id?: string;
geometry: Geometry;
source?: string;
style?: DrawingStyle;
properties?: Record<string, unknown>;
/** Do not round coordinates */
disableRoundCoordinates?: boolean;
/** Hide the marker if it goes beyond the edge of the viewport */
hideOutsideViewport?: HideOutsideRule;
} & DraggableProps<YMapFeatureEventHandler> & BlockingProps & FeatureClickEvents;
declare const defaultProps: Readonly<{
source: "ymaps3x0-default-feature";
}>;
type DefaultProps = typeof defaultProps & {
id: string;
};
/**
* Component for creating a geo object on the map.
* Supports drag-and-drop functionality, drawing styles, and event handling.
* Supported geometries: `Point`, `LineString`, `MultiLineString`, `Polygon` and `MultiPolygon`.
*
* ```javascript
* const feature = new YMapFeature({
* geometry: {
* type: 'LineString',
* coordinates: [
* [37.40108963847453, 55.70173382087952],
* [37.60954231796791, 55.57717912610197]
* ]
* },
* style: {
* stroke: [{width: 12, color: 'rgb(14, 194, 219)'}]
* }})
* map
* .addChild(new YMapDefaultSchemeLayer())
* .addChild(new YMapDefaultFeaturesLayer())
* .addChild(feature);
* ```
* You can add Point geometry with HTMLElement:
* ```javascript
* const feature = new YMapFeature({
* geometry: {
* type: 'Point',
* coordinates: [37.40108963847453, 55.70173382087952]
* },
* style: {
* element: document.createElement('div')
* }
* });
* ```
* But better to use [[YMapMarker]] for this.
*/
declare class YMapFeature extends YMapEntity<YMapFeatureProps, DefaultProps> {
static defaultProps: Readonly<{
source: "ymaps3x0-default-feature";
}>;
private static _uid;
private _id;
private _source;
private _defaultPropsId?;
get id(): string;
constructor(props: YMapFeatureProps);
get properties(): Record<string, unknown> | undefined;
get geometry(): GenericGeometry<LngLat>;
protected _onAttach(): void;
protected _onDetach(): void;
protected _onUpdate({ id, source, geometry }: Partial<YMapFeatureProps>): void;
protected _getDefaultProps(): DefaultProps;
private static _onDragStart;
private static _onDragMove;
private static _onDragEnd;
private static _onClick;
private static _onFastClick;
private static _onDoubleClick;
}
export { YMapFeature, YMapFeatureProps };