UNPKG

rlayers

Version:

React Components for OpenLayers

97 lines 4.33 kB
import { JSX, PropsWithChildren } from 'react'; import { Map as Map, MapBrowserEvent } from 'ol'; import { Feature } from 'ol'; import { FeatureLike } from 'ol/Feature'; import BaseVectorLayer from 'ol/layer/BaseVector'; import CanvasVectorLayerRenderer from 'ol/renderer/canvas/VectorLayer'; import SourceVector from 'ol/source/Vector'; import Geometry from 'ol/geom/Geometry'; import BaseEvent from 'ol/events/Event'; import { OLEvent, RlayersBase } from './REvent'; import { RStyleLike } from './style/RStyle'; export declare class RFeatureUIEvent<F extends FeatureLike> extends MapBrowserEvent<PointerEvent | KeyboardEvent | WheelEvent> { target: F; } export declare class RFeatureBaseEvent<F extends FeatureLike> extends BaseEvent { target: F; } /** * @propsfor RFeature */ export interface RFeatureProps<G extends Geometry = Geometry> extends PropsWithChildren<unknown> { /** OpenLayers geometry, mutually exclusive with feature */ geometry?: G; /** OpenLayers style */ style?: RStyleLike; /** A set of properties that can be accessed later by .get()/.getProperties() */ properties?: Record<string, unknown>; /** * Bind the RFeature to an OpenLayers Feature, mutually exclusive with geometry * * When bound, the RFeature will automatically update its state when the Feature * changes * * geometry is usually a better choice for a dynamic feature */ feature?: Feature<G>; /** Called immediately on click */ onClick?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called on single click when the double click timer has expired */ onSingleClick?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called on double click */ onDblClick?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called on every pointer move when dragging, `e.preventDefault()` * can be used to stop OpenLayers from also panning the map */ onPointerDrag?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called when the object is released */ onPointerDragEnd?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called on every pointer movement over the RFeature, use sparingly */ onPointerMove?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called once when the pointer moves over the RFeature */ onPointerEnter?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called once when the pointer moves out of the RFeature */ onPointerLeave?: (this: RFeature<G>, e: RFeatureUIEvent<Feature<G>>) => boolean | void; /** Called on every change */ onChange?: (this: RFeature<G>, e: RFeatureBaseEvent<Feature<G>>) => void; } type FeatureRef<G extends Geometry = Geometry> = { feature: Feature<G>; layer: BaseVectorLayer<FeatureLike, SourceVector<FeatureLike>, CanvasVectorLayerRenderer>; }; /** * Component for a single vector feature * * Vector features can be either * * * implicit, when loaded from a file as props of a `RLayerVector` * * explicit, when declared as JSX with this component * * Requires a vector layer context * * Provides a location context * * [Example for explicit RFeatures](https://mmomtchev.github.io/rlayers/#/overlays) * * [Example for implicit RFeatures](https://mmomtchev.github.io/rlayers/#/RFeatures) * */ export default class RFeature<G extends Geometry = Geometry> extends RlayersBase<RFeatureProps<G>, Record<string, never>> { private static pointerEvents; private static lastFeaturesEntered; private static lastFeaturesDragged; static hitTolerance: number; ol: Feature<G>; onchange: () => boolean | void; constructor(props: Readonly<RFeatureProps<G>>); static initEventRelay(map: Map): void; protected incrementHandlers(ev: OLEvent): void; protected decrementHandlers(ev: OLEvent): void; protected static dispatchEvent(fr: FeatureRef, event: RFeatureUIEvent<Feature<Geometry>>): boolean; private static eventRelay; protected refresh(prevProps?: RFeatureProps<G>): void; componentDidMount(): void; componentWillUnmount(): void; render(): JSX.Element; } export {}; //# sourceMappingURL=RFeature.d.ts.map