jgis 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,71 @@
1
+ import { WmsOptions, optionsMap } from './types';
2
+ import * as Cesium from 'cesium';
3
+ /**
4
+ * 初始化地图
5
+ * @param {Cesium.Viewer} viewer 视图
6
+ * @param {any} options 配置项
7
+ */
8
+ export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): void;
9
+ /**
10
+ * 创建图层
11
+ * @param {Cesium.Viewer} viewer {Map} 地图
12
+ * @param {string} layerName 图层名称
13
+ * @param {any} data 数据
14
+ * @param options 配置项
15
+ * @returns 图层
16
+ */
17
+ export declare function createLayer<K extends keyof optionsMap>(viewer: Cesium.Viewer, layerName: string, data: any, options: optionsMap[K] & {
18
+ type?: K;
19
+ }): any;
20
+ /**
21
+ * 创建点图层
22
+ * @param viewer 视图
23
+ * @param layerName 图层名称
24
+ * @param data 数据
25
+ * @param options 配置项
26
+ */
27
+ export declare function createPointLayer(viewer: Cesium.Viewer, layerName: string, data: any[], options: optionsMap['Point']): Cesium.BillboardCollection;
28
+ /**
29
+ * 创建线图层
30
+ * @param viewer 视图
31
+ * @param layerName 图层名称
32
+ * @param data 数据
33
+ * @param options 配置项
34
+ * @returns {Cesium.GroundPolylinePrimitive}
35
+ */
36
+ export declare function createLineLayer(viewer: any, layerName: string, data: any[], options: optionsMap['LineString']): Cesium.GroundPolylinePrimitive;
37
+ /**
38
+ * 创建wms图层
39
+ * @param viewer 视图
40
+ * @param layerName 图层名称
41
+ * @param options 配置项
42
+ * @returns {Cesium.ImageryLayer}
43
+ */
44
+ export declare function createWmsLayer(viewer: Cesium.Viewer, layerName: string, options: WmsOptions): Cesium.ImageryLayer;
45
+ /**
46
+ * 创建空白图层
47
+ * @param viewer 视图
48
+ * @param layerName 图层名称
49
+ * @returns {Cesium.DataSource}
50
+ */
51
+ export declare function createBlankLayer(viewer: Cesium.Viewer, layerName: string): Cesium.Primitive;
52
+ /**
53
+ * 根据图层名获取图层
54
+ * @param viewer 视图
55
+ * @param layerName 图层名
56
+ * @returns {Primitive} 图层
57
+ */
58
+ export declare function getLayerByName(viewer: Cesium.Viewer, layerName: string): Cesium.Primitive;
59
+ /**
60
+ * 删除图层
61
+ * @param viewer 视图
62
+ * @param layerName 图层名
63
+ */
64
+ export declare function removeLayer(viewer: any, layerName: any): void;
65
+ /**
66
+ * 隐藏图层
67
+ * @param {Cesium.Viewer} viewer 视图
68
+ * @param {string} layerName 图层名
69
+ * @param {boolean} visible 图层名
70
+ */
71
+ export declare function visibleLayer(viewer: Cesium.Viewer, layerName: string, visible: boolean): void;
@@ -0,0 +1,16 @@
1
+ import { MapContext } from './types';
2
+ /**
3
+ * 注册地图
4
+ * @param id 地图容器的 ID (target)
5
+ */
6
+ export declare const registerMap: (id: string, context: MapContext) => void;
7
+ /**
8
+ * 获取已创建的地图上下文
9
+ * @param id 地图容器的 ID (target)
10
+ */
11
+ export declare function getMapContext(id: string): Promise<MapContext>;
12
+ /**
13
+ * 销毁并移除
14
+ */
15
+ export declare const unregisterMap: (id: string) => void;
16
+ export declare const onMapReady: (id: string, callback: (ctx: MapContext) => void) => void;
@@ -0,0 +1,68 @@
1
+ import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
2
+ import * as Cesium from 'cesium';
3
+ export interface flyOptions {
4
+ heading?: number;
5
+ pitch?: number;
6
+ roll?: number;
7
+ duration?: number;
8
+ maxHeight?: number;
9
+ easing?: (t: number) => number;
10
+ }
11
+ export interface LayerOptions {
12
+ name?: string;
13
+ type?: string;
14
+ data?: any;
15
+ style?: any;
16
+ visible?: boolean;
17
+ opacity?: number;
18
+ interactive?: boolean;
19
+ }
20
+ export interface WmsOptions {
21
+ url: string;
22
+ layers?: string;
23
+ alpha?: number;
24
+ brightness?: number;
25
+ gamma?: number;
26
+ contrast?: number;
27
+ }
28
+ export type ILineOptions = {
29
+ width: number;
30
+ color: string;
31
+ material: Cesium.Material;
32
+ granularity: number;
33
+ };
34
+ export interface optionsMap {
35
+ Point: billboardOptions & {
36
+ getImage?: Function;
37
+ };
38
+ LineString: ILineOptions;
39
+ MultiLineString: ILineOptions;
40
+ Polygon: any;
41
+ MultiPolygon: any;
42
+ Circle: any;
43
+ Wms: WmsOptions;
44
+ Overlay: any;
45
+ }
46
+ export type billboardOptions = Omit<Cesium.Billboard.ConstructorOptions, 'position'>;
47
+ export type Coordinates = [number, number, number];
48
+ export interface MapContext {
49
+ targetId: string;
50
+ instance: Cesium.Viewer;
51
+ addMarker: (layerName: string, data: any, options?: optionsMap['Point']) => void;
52
+ createLayer: <K extends keyof optionsMap>(layerName: string, data: any, options?: optionsMap[K] & {
53
+ type?: K;
54
+ }) => Cesium.Primitive;
55
+ removeLayer: (layerName: string) => void;
56
+ visibleLayer: (layerName: string, visible: boolean) => void;
57
+ getLayerByName: (layerName: string) => Cesium.Primitive;
58
+ createBlankLayer: (layerName: string, options: LayerOptions) => Cesium.Primitive;
59
+ createSelect: (options: SelectOptions) => UseSelectResult;
60
+ createHover: (options: HoverOptions) => UseHoverResult;
61
+ flyTo: (coordinate: Coordinates, options: flyOptions) => Promise<boolean>;
62
+ flyHome: (duration?: number) => void;
63
+ flyToBoundingSphere: (boundingSphere: Cesium.BoundingSphere, options?: flyOptions) => Promise<boolean>;
64
+ setView: (coordinate: Coordinates, options?: flyOptions) => void;
65
+ getMapContext: (id: string) => Promise<MapContext>;
66
+ onMapReady: (id: string, callback: (cxt: MapContext) => void) => void;
67
+ destroyMap: (id: string) => void;
68
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,25 @@
1
1
  export declare const version = "1.0.0";
2
2
  export declare const author = "zhangjianfeng";
3
+ type dataType = {
4
+ lttd?: number;
5
+ lgtd?: number;
6
+ } & {
7
+ jd?: number;
8
+ wd?: number;
9
+ } & {
10
+ latitude?: number;
11
+ longitude?: number;
12
+ } & {
13
+ lon?: number;
14
+ lat?: number;
15
+ };
16
+ /**
17
+ * 解析出数据中的经纬度
18
+ * @param data 数据
19
+ * @returns [经度, 纬度]
20
+ */
21
+ export declare function getLonLat(data: dataType, options?: {
22
+ lonLabel: string;
23
+ latLabel: string;
24
+ }): [number, number];
25
+ export {};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.0.0",o="zhangjianfeng";exports.author=o;exports.version=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="1.0.0",u="zhangjianfeng";function n(e,l){return typeof e!="object"||e===null?null:l&&l.lonLabel&&l.latLabel?[Number(e[l.lonLabel]),Number(e[l.latLabel])]:e.lttd&&e.lgtd?[Number(e.lgtd),Number(e.lttd)]:e.jd&&e.wd?[Number(e.jd),Number(e.wd)]:e.latitude&&e.longitude?[Number(e.longitude),Number(e.latitude)]:e.lon&&e.lat?[Number(e.lon),Number(e.lat)]:null}exports.author=u;exports.getLonLat=n;exports.version=r;
package/dist/index.mjs CHANGED
@@ -1,5 +1,9 @@
1
- const n = "1.0.0", o = "zhangjianfeng";
1
+ const r = "1.0.0", u = "zhangjianfeng";
2
+ function n(e, l) {
3
+ return typeof e != "object" || e === null ? null : l && l.lonLabel && l.latLabel ? [Number(e[l.lonLabel]), Number(e[l.latLabel])] : e.lttd && e.lgtd ? [Number(e.lgtd), Number(e.lttd)] : e.jd && e.wd ? [Number(e.jd), Number(e.wd)] : e.latitude && e.longitude ? [Number(e.longitude), Number(e.latitude)] : e.lon && e.lat ? [Number(e.lon), Number(e.lat)] : null;
4
+ }
2
5
  export {
3
- o as author,
4
- n as version
6
+ u as author,
7
+ n as getLonLat,
8
+ r as version
5
9
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 防抖函数
3
+ * @param fn 函数
4
+ * @param wait 等待时间
5
+ * @returns 函数
6
+ */
7
+ export declare function throttle(fn: any, delay?: number): (...args: any[]) => void;
package/package.json CHANGED
@@ -1,70 +1,70 @@
1
- {
2
- "name": "jgis",
3
- "version": "1.0.2",
4
- "description": "快速创建二维、三维工具库",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "lint:prettier": "prettier --write **/*.{js,ts,json,tsx,css,less,scss,vue,html,md}",
11
- "eslint:fix": "eslint --fix",
12
- "build": "vite build"
13
- },
14
- "files": [
15
- "dist",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "exports": {
20
- ".": {
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.js",
23
- "types": "./dist/index.d.ts"
24
- },
25
- "./2d": {
26
- "import": "./dist/2d/index.mjs",
27
- "require": "./dist/2d/index.js",
28
- "types": "./dist/2d/index.d.ts"
29
- },
30
- "./3d": {
31
- "import": "./dist/3d/index.mjs",
32
- "require": "./dist/3d/index.js",
33
- "types": "./dist/3d/index.d.ts"
34
- }
35
- },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/Guidozijef/jgis.git"
39
- },
40
- "keywords": [
41
- "gis",
42
- "openlayers",
43
- "cesium",
44
- "typeScript"
45
- ],
46
- "author": "zhangjianfeng",
47
- "license": "ISC",
48
- "bugs": {
49
- "url": "https://github.com/Guidozijef/jgis/issues"
50
- },
51
- "homepage": "https://github.com/Guidozijef/jgis#readme",
52
- "devDependencies": {
53
- "@eslint/js": "^9.39.2",
54
- "@turf/turf": "^7.3.1",
55
- "cesium": "^1.137.0",
56
- "eslint": "^9.39.2",
57
- "eslint-config-prettier": "^10.1.8",
58
- "eslint-plugin-prettier": "^5.5.4",
59
- "eslint-plugin-vue": "^10.6.2",
60
- "globals": "^17.0.0",
61
- "jiti": "^2.6.1",
62
- "ol": "^10.7.0",
63
- "prettier": "^3.7.4",
64
- "ts-loader": "^9.5.4",
65
- "typescript": "^5.9.3",
66
- "typescript-eslint": "^8.51.0",
67
- "vite": "^7.3.0",
68
- "vite-plugin-dts": "^4.5.4"
69
- }
70
- }
1
+ {
2
+ "name": "jgis",
3
+ "version": "1.0.4",
4
+ "description": "快速创建二维、三维工具库",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "lint:prettier": "prettier --write **/*.{js,ts,json,tsx,css,less,scss,vue,html,md}",
11
+ "eslint:fix": "eslint --fix",
12
+ "build": "vite build"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.js",
23
+ "types": "./dist/index.d.ts"
24
+ },
25
+ "./2d": {
26
+ "import": "./dist/2d/index.mjs",
27
+ "require": "./dist/2d/index.js",
28
+ "types": "./dist/2d/index.d.ts"
29
+ },
30
+ "./3d": {
31
+ "import": "./dist/3d/index.mjs",
32
+ "require": "./dist/3d/index.js",
33
+ "types": "./dist/3d/index.d.ts"
34
+ }
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/Guidozijef/jgis.git"
39
+ },
40
+ "keywords": [
41
+ "gis",
42
+ "openlayers",
43
+ "cesium",
44
+ "typeScript"
45
+ ],
46
+ "author": "zhangjianfeng",
47
+ "license": "ISC",
48
+ "bugs": {
49
+ "url": "https://github.com/Guidozijef/jgis/issues"
50
+ },
51
+ "homepage": "https://github.com/Guidozijef/jgis#readme",
52
+ "devDependencies": {
53
+ "@eslint/js": "^9.39.2",
54
+ "@turf/turf": "^7.3.1",
55
+ "cesium": "^1.137.0",
56
+ "eslint": "^9.39.2",
57
+ "eslint-config-prettier": "^10.1.8",
58
+ "eslint-plugin-prettier": "^5.5.4",
59
+ "eslint-plugin-vue": "^10.6.2",
60
+ "globals": "^17.0.0",
61
+ "jiti": "^2.6.1",
62
+ "ol": "^10.7.0",
63
+ "prettier": "^3.7.4",
64
+ "ts-loader": "^9.5.4",
65
+ "typescript": "^5.9.3",
66
+ "typescript-eslint": "^8.51.0",
67
+ "vite": "^7.3.0",
68
+ "vite-plugin-dts": "^4.5.4"
69
+ }
70
+ }
@@ -1,23 +0,0 @@
1
- import { Map } from 'ol';
2
- import { JGisInstance, JGisConfig, JGisInitOptions } from './types';
3
- export default class JGis implements JGisInstance {
4
- protected Map: Map;
5
- protected config: JGisConfig;
6
- constructor(map: Map, options: JGisConfig);
7
- init(options: JGisInitOptions): void;
8
- /**
9
- * 移动事件
10
- * @param options
11
- */
12
- private moveEvent;
13
- /**
14
- * 点击事件
15
- * @param options
16
- */
17
- private clickEvent;
18
- private handleClick;
19
- /**
20
- * 清除选中要素
21
- */
22
- clearSelectFeature(): void;
23
- }