@igo2/geo
Version:
200 lines (199 loc) • 7.02 kB
TypeScript
import { ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';
import type { Type } from 'ol/geom/Geometry';
import OlVectorSource from 'ol/source/Vector';
import * as OlStyle from 'ol/style';
import { StyleLike as OlStyleLike } from 'ol/style/Style';
import { IgoMap } from '../../map/shared/map';
import { DrawControl, ModifyControl } from '../shared/controls';
import { GeoJSONGeometry } from '../shared/geometry.interfaces';
import * as i0 from "@angular/core";
/**
* This input allows a user to draw a new geometry or to edit
* an existing one on a map. A text input is also displayed in the
* form with some instructions.
* This is still WIP.
*/
export declare class GeometryFormFieldInputComponent implements OnInit, OnDestroy, ControlValueAccessor {
private cdRef;
ngControl: NgControl;
private olOverlayLayer;
private olGeoJSON;
private ready;
private drawControl;
private modifyControl;
private defaultDrawStyleRadius;
private olGeometryEnds$$;
private olGeometryChanges$$;
private olTooltip;
/**
* Active control
* @internal
*/
activeControl: DrawControl | ModifyControl;
/**
* The map to draw the geometry on
*/
map: IgoMap;
/**
* The geometry type
*/
set geometryType(value: Type);
get geometryType(): Type;
private _geometryType;
/**
* The drawGuide around the mouse pointer to help drawing
*/
drawGuide: number;
/**
* Whether a measure tooltip should be displayed
*/
measure: boolean;
/**
* Whether draw control should be active or not
*/
get drawControlIsActive(): boolean;
set drawControlIsActive(value: boolean);
private _drawControlIsActive;
/**
* Whether freehand draw control should be active or not
*/
get freehandDrawIsActive(): boolean;
set freehandDrawIsActive(value: boolean);
private _freehandDrawIsActive;
/**
* Whether freehand draw control should be active or not
*/
get predefinedRadius(): boolean;
set predefinedRadius(value: boolean);
private _predefinedRadius;
/**
* Control options
*/
controlOptions: Record<string, any>;
/**
* Style for the draw control (applies while the geometry is being drawn)
*/
set drawStyle(value: OlStyleLike | OlStyle.RegularShape);
get drawStyle(): OlStyleLike | OlStyle.RegularShape;
private _drawStyle;
/**
* Style for the overlay layer (applies once the geometry is added to the map)
* If not specified, drawStyle applies
*/
set overlayStyle(value: OlStyleLike | OlStyle.RegularShape);
get overlayStyle(): OlStyleLike | OlStyle.RegularShape;
private _overlayStyle;
/**
* The geometry value (GeoJSON)
* Implemented as part of ControlValueAccessor.
*/
set value(value: GeoJSONGeometry);
get value(): GeoJSONGeometry;
private _value;
/**
* The vector source to add the geometry to
* @internal
*/
get olOverlaySource(): OlVectorSource;
set radius(value: any);
constructor(cdRef: ChangeDetectorRef, ngControl: NgControl);
/**
* Create an overlay layer, add the initial geometry to it (if any)
* and toggle the right interaction.
* @internal
*/
ngOnInit(): void;
/**
* Clear the overlay layer and any interaction added by this component.
* @internal
*/
ngOnDestroy(): void;
/**
* Implemented as part of ControlValueAccessor.
*/
registerOnChange(fn: () => void): void;
private onChange;
/**
* Implemented as part of ControlValueAccessor.
*/
registerOnTouched(fn: () => void): void;
private onTouched;
/**
* Implemented as part of ControlValueAccessor.
*/
writeValue(value: GeoJSONGeometry): void;
/**
* Add an overlay layer to the map
*/
private addOlOverlayLayer;
/**
* Create a draw control and subscribe to it's geometry
*/
private createDrawControl;
/**
* Create a modify control and subscribe to it's geometry
*/
private createModifyControl;
/**
* Toggle the proper control (draw or modify)
*/
private toggleControl;
/**
* Activate a given control
* @param control Control
*/
private activateControl;
/**
* Deactivate the active control
*/
private deactivateControl;
/**
* Update measures observables and map tooltips
* @param olGeometry Ol linestring or polygon
*/
private onOlGeometryEnds;
/**
* Update measures observables and map tooltips
* @param olGeometry Ol linestring or polygon
*/
private onOlGeometryChanges;
/**
* When drawing ends, convert the output value to GeoJSON and keep it.
* Restore the double click interaction.
* @param olGeometry OL geometry
*/
private setOlGeometry;
private circleToPoint;
/**
* Add a GeoJSON geometry to the overlay
* @param geometry GeoJSON geometry
*/
private addGeoJSONToOverlay;
/**
* Create the measure tooltip
*/
private createMeasureTooltip;
/**
* Update the measure tooltip of an OL geometry
* @param olGeometry OL Geometry
*/
private updateMeasureTooltip;
/**
* Remove the measure tooltip from the map
*/
private removeMeasureTooltip;
/**
* Adjust the draw style with the specified draw guide distance, if possible
* @param olStyle Draw style to update
* @param resolution Resolution (to make the screen size of symbol fit the drawGuide value)
*/
private updateDrawStyleWithDrawGuide;
/**
* Returns wether a given Open Layers style has a radius property that can be set (used to set draw guide)
* @param olStyle The style on which to perform the check
*/
private getGuideStyleFromDrawStyle;
static ɵfac: i0.ɵɵFactoryDeclaration<GeometryFormFieldInputComponent, [null, { optional: true; self: true; }]>;
static ɵcmp: i0.ɵɵComponentDeclaration<GeometryFormFieldInputComponent, "igo-geometry-form-field-input", never, { "map": { "alias": "map"; "required": false; }; "geometryType": { "alias": "geometryType"; "required": false; }; "drawGuide": { "alias": "drawGuide"; "required": false; }; "measure": { "alias": "measure"; "required": false; }; "drawControlIsActive": { "alias": "drawControlIsActive"; "required": false; }; "freehandDrawIsActive": { "alias": "freehandDrawIsActive"; "required": false; }; "predefinedRadius": { "alias": "predefinedRadius"; "required": false; }; "controlOptions": { "alias": "controlOptions"; "required": false; }; "drawStyle": { "alias": "drawStyle"; "required": false; }; "overlayStyle": { "alias": "overlayStyle"; "required": false; }; "value": { "alias": "value"; "required": false; }; "radius": { "alias": "radius"; "required": false; }; }, {}, never, never, true, never>;
}