gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
260 lines (259 loc) • 7.7 kB
TypeScript
import Graphic from '@arcgis/core/Graphic.js';
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
import MapView from '@arcgis/core/views/MapView';
import SceneView from '@arcgis/core/views/SceneView';
import Sketch from '@arcgis/core/widgets/Sketch';
import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
import * as turf from '@turf/turf';
interface sketchViewOptions {
/**
* 最大允许绘制的图形数量
*/
maxAllowedGraphics?: number;
/**
* 图形图层配置
*/
GraphicsLayer?: {};
/**
* 绘制工具显示的元素
*/
sketchVisibleElements?: {};
/**
* 绘制工具显示的位置
*/
sketchPosition?: string;
/**
* 绘制工具默认是否显示
*
* @type {boolean}
* @memberof sketchViewOptions
*/
defaultSketchVisible?: boolean;
sketchViewModelItemSymbol?: {
polylineSymbol?: any;
polygonSymbol?: any;
pointSymbol?: any;
};
}
interface ITPoint {
x: number;
y: number;
}
declare type LinearUnits = 'meters' | 'feet' | 'kilometers' | 'miles' | 'nautical-miles' | 'yards' | number;
declare type Direction = 'north' | 'east' | 'south' | 'west';
declare type dimensionTypeFace = 'distance' | 'area' | 'angle' | null;
export default class sketchViewTool {
private viewer;
graphicsLayer: GraphicsLayer;
textGraphicsLayer: GraphicsLayer;
sketchViewModel: SketchViewModel;
sketch: Sketch;
options: sketchViewOptions;
/**
* 是否正在绘制
*
* @type {boolean}
* @memberof sketchViewTool
*/
isDraw: boolean;
/**
* 当前绘制的图形
*/
drawStartGraphic: __esri.Geometry | null;
/**
* 当前绘制的图形的id
*
* @type {(string | null)}
* @memberof sketchViewTool
*/
drawStartGraphicId: string | null;
/**
* 绘制的提示dom
*
* @type {(HTMLElement | null)}
* @memberof sketchViewTool
*/
tipsDom: HTMLElement | null;
drawPointGraphic: Map<string, Graphic>;
dimensionType: dimensionTypeFace;
constructor(view: MapView | SceneView, options?: sketchViewOptions);
init(): void;
on(callback?: (type: string, state: string, event: any) => void): void;
onCreate(event: __esri.SketchCreateEvent, callback?: (type: string, state: string, event?: any) => void): void;
onCreateToCancel(): void;
onUpdate(event: __esri.SketchUpdateEvent, callback?: (type: string, state: string, event?: any) => void): void;
onDelete(event: __esri.SketchDeleteEvent, callback?: (type: string, state: string, event: any) => void): void;
addPolyline(paths: number[][][]): void;
createPolylineGraphic(paths: number[][], lineSymbol: any, attributes: any): Graphic;
createDom(): HTMLDivElement | undefined;
removeDom(): void;
/**
* 开始绘制
* @param tool 'point' | 'polyline' | 'polygon' | 'rectangle' | 'circle'
* @param createOptions
*/
sketchCreate(tool: 'point' | 'polyline' | 'polygon' | 'rectangle' | 'circle', createOptions?: __esri.SketchViewModelCreateCreateOptions): void;
/**
* 退出绘制
*
* @memberof sketchViewTool
*/
sketchCancel(): void;
/**
* 获取所有的图形得长度
* @param offsetUnit 距离单位
* @returns
*/
getCalculateDistance(offsetUnit?: LinearUnits): (string | number)[];
/**
* 获取所有的图形得航向角
*
* @returns
* @memberof sketchViewTool
*/
getCalculateHeading(direction?: Direction): (string | number)[];
/**
* 获取所有的线段的路径和长度
*
* @returns
* @memberof sketchViewTool
*/
getAllPolylineGraphicPath(offsetUnit?: LinearUnits): {
paths: number[][];
distance: number;
}[];
close(): void;
show(): void;
removeAll(): void;
calculateDistance(geometry: __esri.Geometry, offsetUnit?: LinearUnits): number;
/**
* 计算geometry的航向角
*
* @param {__esri.Geometry} geometry
* @param {string} [direction='north']
* @returns
* @memberof sketchViewTool
*/
calculateHeading(geometry: __esri.Geometry, direction?: string): number;
/**
* 计算路径的航向角
*
* @param {number[][]} path 路径
* @param {string} [direction='north'] 方向
* @returns
* @memberof sketchViewTool
*/
calculatePointHeading(path: number[][], direction?: string): number;
drawPolylinePoint(drawStartGraphic: __esri.Geometry, parentId: string, actions?: string): void;
updatePolylinePoint(drawStartGraphic: Graphic[]): void;
deletePolylinePoint(drawStartGraphic: Graphic[]): void;
/**
* 添加或者更新标记点
*
* @param {string} text 标记点的文本
* @param {ITPoint} point 标记点的坐标
* @param {string} id 标记点的id
* @param {*} [attributes={}] 标记点的属性
* @returns
* @memberof sketchViewTool
*/
addOrUpdateMarkPoint(text: string, point: ITPoint, id: string, attributes?: any): void;
/**
* 获取图形的点位
*
* @param {__esri.Geometry} geometry
* @returns
* @memberof sketchViewTool
*/
getGeometryXY(geometry: __esri.Geometry, index?: number): {
x: number;
y: number;
};
/**
* 创建文本图形
*
* @param {string} text 文本
* @param {{ x: number; y: number }} point 坐标
* @param {*} [attributes={}] 属性
* @returns
* @memberof sketchViewTool
*/
createTextGraphic(text: string, point: {
x: number;
y: number;
}, attributes?: any): Graphic;
/**
* 获取当前绘制的图形的长度
* @returns
*/
getDrawGraphicLength(): string | 0;
/**
* 获取两点的角度
*
* @param {ITPoint} startPoint
* @param {ITPoint} endPoint
* @returns
* @memberof SketchView
*/
getAngle(startPoint: ITPoint, endPoint: ITPoint): number;
/**
* 获取两点的方位角
*
* @param {ITPoint} startPoint
* @param {ITPoint} endPoint
* @returns
* @memberof sketchViewTool
*/
getBearing(startPoint: ITPoint, endPoint: ITPoint): number;
/**
* 获取两点的距离
* @param startPoint
* @param endPoint
* @param units
* @returns
*/
getPointLength(paths: number[][], units?: LinearUnits): number;
/**
* 获取多个点的中心点
*
* @param {ITPoint[]} points
* @returns
* @memberof sketchViewTool
*/
featureCollection(points: ITPoint[]): turf.helpers.Feature<turf.helpers.Point, turf.helpers.Properties>;
/**
* 获取两点的中心点
*
* @param {ITPoint} startPoint
* @param {ITPoint} endPoint
* @returns
* @memberof sketchViewTool
*/
midpoint(startPoint: ITPoint, endPoint: ITPoint): turf.helpers.Feature<turf.helpers.Point, turf.helpers.Properties>;
/**
* 获取方向
*
* @param {ITPoint} startPoint 起点
* @param {ITPoint} endPoint 终点
* @returns
* @memberof SketchView
*/
getDirection(startPoint: ITPoint, endPoint: ITPoint): 0 | 1 | 2 | 3;
findLayerById(id: string): __esri.Layer;
/**
* 开启图层捕捉
*/
turnOnLayerSnap(): void;
/**
* 关闭图层捕捉
*/
turnOffLayerSnap(): void;
setDimensionType(Type: dimensionTypeFace): void;
/**
* 删除指定的图形
* @param graphic 删除指定的图形
*/
remove(graphic: any): void;
destroy(): void;
}
export {};