jgis 1.0.0

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,70 @@
1
+ import { Map } from 'ol';
2
+ import { Layer, Tile as TileLayer, Vector as VectorLayer } from 'ol/layer';
3
+ import { TileWMS, XYZ } from 'ol/source';
4
+ import { LayerOptions, MapInstance, GeoJsonLike, OverlayResult, BaseLayerOptions } from './types';
5
+ /**
6
+ * 创建底图
7
+ * @param map 地图实例
8
+ * @param options 图层配置
9
+ * @returns {TileLayer} 图层实例
10
+ */
11
+ export declare function createBaseLayer(map: Map, options?: BaseLayerOptions): TileLayer<XYZ>;
12
+ /**
13
+ * 创建图层
14
+ * @param map {Map} 地图
15
+ * @param layerName 图层名称
16
+ * @param data 数据
17
+ * @param options 配置项
18
+ * @returns 图层
19
+ */
20
+ export declare function createLayer(map: Map, layerName: string, data: any, options: LayerOptions): Layer;
21
+ /**
22
+ * 移除图层
23
+ * @param map 地图实例
24
+ * @param layerName 图层名称
25
+ * @returns void
26
+ */
27
+ export declare function removeLayer(map: Map, layerName: string | string[]): void;
28
+ /**
29
+ * 根据GEOJSON数据创建图层
30
+ * @param layerName 图层名称
31
+ * @param geoJson GeoJson数据
32
+ * @param Map 地图实例
33
+ * @param options 图层配置
34
+ * @returns {VectorLayer} 矢量图层
35
+ */
36
+ export declare function createJSONLayer(layerName: string, geoJson: GeoJsonLike, Map: MapInstance, options: LayerOptions): VectorLayer;
37
+ /**
38
+ * 根据WMS服务创建图层
39
+ * @param layerName 图层名称
40
+ * @param Map 地图实例
41
+ * @param options 图层配置
42
+ * @returns {TileLayer} 矢量图层
43
+ */
44
+ export declare function createWmsLayer(layerName: string, Map: MapInstance, options: LayerOptions): TileLayer<TileWMS>;
45
+ /**
46
+ * 根据数据创建矢量图层
47
+ * @param layerName 图层名称
48
+ * @param data 图层数据
49
+ * @param Map 地图实例
50
+ * @param options 图层配置
51
+ * @returns {TileLayer} 矢量图层
52
+ */
53
+ export declare function createVectorLayer(layerName: string, data: any[], Map: MapInstance, options: LayerOptions): VectorLayer;
54
+ /**
55
+ * 根据数据创建矢量图层
56
+ * @param layerName 图层名称
57
+ * @param data 图层数据
58
+ * @param Map 地图实例
59
+ * @param options 图层配置
60
+ * @returns {TileLayer} 矢量图层
61
+ */
62
+ export declare function createBufferCircle(layerName: string, data: any, Map: MapInstance, options: LayerOptions): VectorLayer;
63
+ export declare function createOverlayLayer(layerName: string, data: any, Map: MapInstance, options: LayerOptions): OverlayResult;
64
+ export declare function createBlankLayer(layerName: string, options: LayerOptions): VectorLayer;
65
+ /**
66
+ * 根据图层名称获取图层
67
+ * @param map 地图实例
68
+ * @param layerName 图层名称
69
+ */
70
+ export declare function getLayerByName(map: Map, layerName: string): any;
@@ -0,0 +1,24 @@
1
+ import { Vector as VectorSource, TileWMS } from 'ol/source';
2
+ import { LayerOptions } from './types';
3
+ import { Map } from 'ol';
4
+ /**
5
+ * 创建数据源
6
+ * @param layerName 图层名称
7
+ * @param data 数据
8
+ * @param options 配置项
9
+ * @returns 数据源
10
+ */
11
+ export declare function createSources(layerName: string, data: any[], options: LayerOptions): VectorSource;
12
+ /**
13
+ * 创建WMS数据源
14
+ * @param data 数据
15
+ * @param options 配置项
16
+ * @returns TileWMS数据源
17
+ */
18
+ export declare function createSourceByWms(data: any, options: LayerOptions): TileWMS;
19
+ /**
20
+ * 根据图层名称获取图层数据源
21
+ * @param map 地图实例
22
+ * @param layerName 图层名称
23
+ */
24
+ export declare function getSourceByName(map: Map, layerName: string): any;
@@ -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,2 @@
1
+ import { StyleLike } from 'ol/style/Style';
2
+ export declare function generateStyle(layerName: string, options: any): StyleLike | null;
@@ -0,0 +1,80 @@
1
+ import { Map, Feature } from 'ol';
2
+ import { StyleLike, default as Style } from 'ol/style/Style';
3
+ import { Layer } from 'ol/layer';
4
+ import { FeatureLike } from 'ol/Feature';
5
+ import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
6
+ export interface BaseLayerOptions {
7
+ token?: string;
8
+ maxZoom?: number;
9
+ minZoom?: number;
10
+ zIndex?: number;
11
+ baseType?: string;
12
+ noteType?: string;
13
+ }
14
+ export interface mapConfigOptions {
15
+ projection?: string;
16
+ center?: number[];
17
+ zoom?: number;
18
+ minZoom?: number;
19
+ maxZoom?: number;
20
+ baseLayers: BaseLayerOptions;
21
+ }
22
+ export interface FeatureCallbackParams {
23
+ layerName: string;
24
+ feature: Feature | null;
25
+ overlay?: Layer | null;
26
+ deFeature?: Feature | null;
27
+ event: any;
28
+ }
29
+ export interface LayerOptions {
30
+ type?: 'GeoJSON' | 'Wms' | 'Point' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon' | 'Circle' | 'Overlay';
31
+ token?: string;
32
+ style?: Style;
33
+ getStyle?: (layerName: string, feature: FeatureLike, resolution: number) => void | Style | Style[];
34
+ zIndex?: number;
35
+ cqlFilter?: string;
36
+ [key: string]: any;
37
+ }
38
+ export interface HighLightOptions {
39
+ style?: StyleLike;
40
+ getStyle: (layerName: string, feature: Feature) => StyleLike;
41
+ time?: number;
42
+ }
43
+ export interface FlashOptions extends HighLightOptions {
44
+ }
45
+ export type MapLike = any;
46
+ export type MapInstance = Map;
47
+ export type GeoJsonLike = any;
48
+ export type customFeature = {
49
+ running: boolean;
50
+ clearFlash: () => void;
51
+ };
52
+ export interface OverlayResult {
53
+ overlayer: import('ol/Overlay').default;
54
+ content: HTMLDivElement;
55
+ }
56
+ export interface flyOptions {
57
+ zoom?: number;
58
+ duration?: number;
59
+ extend?: number[];
60
+ rotation?: number;
61
+ easing?: (t: number) => number;
62
+ }
63
+ export interface MapContext {
64
+ targetId: string;
65
+ instance: MapInstance;
66
+ addMarker: (layerName: string, data: any, options?: LayerOptions) => void;
67
+ createLayer: (layerName: string, data: any, options?: LayerOptions) => Layer;
68
+ removeLayer: (layerName: string) => void;
69
+ useSelect: (options: SelectOptions) => UseSelectResult;
70
+ useHover: (options: HoverOptions) => UseHoverResult;
71
+ flyTo: (coordinate: [number, number], options: flyOptions) => void;
72
+ flyToByExtent: (options: flyOptions) => void;
73
+ flyToByFeature: (feature: Feature, options: flyOptions) => void;
74
+ getProjection: () => void;
75
+ getZoom: () => number;
76
+ setZoom: (zoom: number) => void;
77
+ getMapContext: (id: string) => Promise<MapContext>;
78
+ onMapReady: (id: string, callback: () => void) => void;
79
+ destroyMap: (id: string) => void;
80
+ }
@@ -0,0 +1,57 @@
1
+ import { Map } from 'ol';
2
+ import { FeatureLike } from 'ol/Feature';
3
+ import { customFeature, FlashOptions, HighLightOptions } from './types';
4
+ type dataType = {
5
+ lttd?: number;
6
+ lgtd?: number;
7
+ } & {
8
+ jd?: number;
9
+ wd?: number;
10
+ } & {
11
+ latitude?: number;
12
+ longitude?: number;
13
+ } & {
14
+ lon?: number;
15
+ lat?: number;
16
+ };
17
+ /**
18
+ * 解析出数据中的经纬度
19
+ * @param data 数据
20
+ * @returns [经度, 纬度]
21
+ */
22
+ export declare function getLonLat(data: dataType): [number, number];
23
+ /**
24
+ * 根据图层名称删除图层
25
+ * @param map 地图实例
26
+ * @param layerName 图层名称
27
+ */
28
+ export declare function removeLayerByName(map: Map, layerName: string): void;
29
+ /**
30
+ * 高亮要素
31
+ * @param layerName 图层名称
32
+ * @param feature 要素
33
+ * @param options 配置
34
+ * @param zoomFlag 是否高亮 默认false
35
+ */
36
+ export declare function lightFeature(layerName: string, feature: FeatureLike, options: HighLightOptions, zoomFlag?: boolean): void;
37
+ /**
38
+ * 闪烁要素
39
+ * @param layerName 图层名称
40
+ * @param feature 要素
41
+ * @param options 配置
42
+ */
43
+ export declare function flashFeature(layerName: string, feature: FeatureLike & customFeature, options: FlashOptions): void;
44
+ /**
45
+ * 根据数据查询要素
46
+ * @param layerName 图层名称
47
+ * @param properties 数据
48
+ * @returns Feature 要素
49
+ */
50
+ export declare function queryFeatures(layerName: string, properties: any): FeatureLike | undefined;
51
+ export declare function getSelectedFtByEvt(event: any): {
52
+ layerName?: string;
53
+ feature?: FeatureLike;
54
+ properties?: any;
55
+ };
56
+ export declare function getSelectedFtByWms(evt: any): any;
57
+ export {};
package/dist/2d.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './2d/index'
2
+ export {}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 添加天地图
3
+ *
4
+ * @param {Object} [viewer] Cesium.viewer对象
5
+ * @param {Boolean} [addImg_w] 控制添加天地图影像底图
6
+ * @param {Boolean} [addIbo_w] 控制添加天地图影像国界
7
+ * @param {Boolean} [addCia_w] 控制添加天地图影像注记
8
+ * @param {String} [tokenString] 天地图对应token
9
+ */
10
+ export declare function addTDTImageryProvider(viewer: any, options: any): void;
File without changes
@@ -0,0 +1,19 @@
1
+ import * as Cesium from 'cesium';
2
+ /**
3
+ * 创建Viewer
4
+ *
5
+ * @param {String} [divStr] Cesium.viewer对应的DOM元素名:<div id="cesiumContainer"></div>
6
+ * @param {String} [terrainUrl] 地形链接
7
+ */
8
+ export declare function CreateViewer(el: HTMLElement, terrainUrl?: string): Cesium.Viewer;
9
+ /**
10
+ * 初始化地图
11
+ * @param {Cesium.Viewer} viewer
12
+ */
13
+ export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): void;
14
+ /**
15
+ * 添加标记
16
+ * @param {Cesium.Viewer} viewer
17
+ * @returns {void}
18
+ */
19
+ export declare function addMarker(viewer: Cesium.Viewer, points: any[], markerOptions: any): void;
File without changes
@@ -0,0 +1,4 @@
1
+ export declare function useMap(el: HTMLElement, options: any): {
2
+ instance: import('cesium').Viewer;
3
+ addMarker: (points: any[], markerOptions: any) => void;
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";var d=(r,t,e)=>new Promise((a,l)=>{var c=n=>{try{s(e.next(n))}catch(o){l(o)}},m=n=>{try{s(e.throw(n))}catch(o){l(o)}},s=n=>n.done?a(n.value):Promise.resolve(n.value).then(c,m);s((e=e.apply(r,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("cesium");function f(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const i=f(g);function y(r,t){const e={img_w:!0,ibo_w:!0,cia_w:!0,token:"dadcbbdb5206b626a29ca739686b3087"},{img_w:a,ibo_w:l,cia_w:c,token:m}=Object.assign(e,t),s="https://t{s}.tianditu.gov.cn/",n=["0","1","2","3","4","5","6","7"];if(a){const o=new i.UrlTemplateImageryProvider({url:s+"DataServer?T=img_w&x={x}&y={y}&l={z}&tk="+m,subdomains:n,tilingScheme:new i.WebMercatorTilingScheme,maximumLevel:18});let u=r.imageryLayers.addImageryProvider(o);u.gamma=1}else{const o=new i.UrlTemplateImageryProvider({url:"https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",subdomains:["a","b","c","d"],tilingScheme:new i.WebMercatorTilingScheme,maximumLevel:18});r.imageryLayers.addImageryProvider(o)}if(l){const o=new i.UrlTemplateImageryProvider({url:s+"DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk="+m,subdomains:n,tilingScheme:new i.WebMercatorTilingScheme,maximumLevel:10});r.imageryLayers.addImageryProvider(o)}if(c){const o=new i.UrlTemplateImageryProvider({url:s+"DataServer?T=cia_w&x={x}&y={y}&l={z}&tk="+m,subdomains:n,tilingScheme:new i.WebMercatorTilingScheme,maximumLevel:18});r.imageryLayers.addImageryProvider(o)}}function b(r,t){let e;i.defined(t)&&(e=d(null,null,function*(){return yield i.CesiumTerrainProvider.fromUrl(t,{requestVertexNormals:!0,requestWaterMask:!0})})),i.defined(e)||(e=new i.EllipsoidTerrainProvider);const a=new i.Viewer(r,{requestRenderMode:!0,maximumRenderTimeChange:1/0,selectionIndicator:!1,animation:!1,timeline:!1,geocoder:!1,homeButton:!1,baseLayerPicker:!1,imageryProvider:new i.GridImageryProvider,sceneModePicker:!1,navigationHelpButton:!1,infoBox:!1,fullscreenButton:!1,shouldAnimate:!0,terrainProvider:e,contextOptions:{webgl:{preserveDrawingBuffer:!0}}});return a._cesiumWidget._creditContainer.style.display="none",a}function v(r,t){y(r,t)}function p(r,t,e){console.log("添加标记",r,t,e)}function w(r,t){const e=b(r);return v(e,t),{instance:e,addMarker:(a,l)=>p(e,a,l)}}exports.useMap=w;
@@ -0,0 +1,120 @@
1
+ var c = (r, a, e) => new Promise((o, s) => {
2
+ var d = (t) => {
3
+ try {
4
+ m(e.next(t));
5
+ } catch (n) {
6
+ s(n);
7
+ }
8
+ }, l = (t) => {
9
+ try {
10
+ m(e.throw(t));
11
+ } catch (n) {
12
+ s(n);
13
+ }
14
+ }, m = (t) => t.done ? o(t.value) : Promise.resolve(t.value).then(d, l);
15
+ m((e = e.apply(r, a)).next());
16
+ });
17
+ import * as i from "cesium";
18
+ function g(r, a) {
19
+ const e = {
20
+ img_w: !0,
21
+ ibo_w: !0,
22
+ cia_w: !0,
23
+ token: "dadcbbdb5206b626a29ca739686b3087"
24
+ }, { img_w: o, ibo_w: s, cia_w: d, token: l } = Object.assign(e, a), m = "https://t{s}.tianditu.gov.cn/", t = ["0", "1", "2", "3", "4", "5", "6", "7"];
25
+ if (o) {
26
+ const n = new i.UrlTemplateImageryProvider({
27
+ url: m + "DataServer?T=img_w&x={x}&y={y}&l={z}&tk=" + l,
28
+ subdomains: t,
29
+ tilingScheme: new i.WebMercatorTilingScheme(),
30
+ maximumLevel: 18
31
+ });
32
+ let u = r.imageryLayers.addImageryProvider(n);
33
+ u.gamma = 1;
34
+ } else {
35
+ const n = new i.UrlTemplateImageryProvider({
36
+ url: "https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",
37
+ subdomains: ["a", "b", "c", "d"],
38
+ tilingScheme: new i.WebMercatorTilingScheme(),
39
+ maximumLevel: 18
40
+ });
41
+ r.imageryLayers.addImageryProvider(n);
42
+ }
43
+ if (s) {
44
+ const n = new i.UrlTemplateImageryProvider({
45
+ url: m + "DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=" + l,
46
+ subdomains: t,
47
+ tilingScheme: new i.WebMercatorTilingScheme(),
48
+ maximumLevel: 10
49
+ });
50
+ r.imageryLayers.addImageryProvider(n);
51
+ }
52
+ if (d) {
53
+ const n = new i.UrlTemplateImageryProvider({
54
+ url: m + "DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=" + l,
55
+ subdomains: t,
56
+ tilingScheme: new i.WebMercatorTilingScheme(),
57
+ maximumLevel: 18
58
+ });
59
+ r.imageryLayers.addImageryProvider(n);
60
+ }
61
+ }
62
+ function y(r, a) {
63
+ let e;
64
+ i.defined(a) && (e = c(null, null, function* () {
65
+ return yield i.CesiumTerrainProvider.fromUrl(a, {
66
+ requestVertexNormals: !0,
67
+ requestWaterMask: !0
68
+ });
69
+ })), i.defined(e) || (e = new i.EllipsoidTerrainProvider());
70
+ const o = new i.Viewer(r, {
71
+ requestRenderMode: !0,
72
+ //减少应用程序的 CPU/GPU 使用率
73
+ maximumRenderTimeChange: 1 / 0,
74
+ //默认时间变化请求一个新帧
75
+ selectionIndicator: !1,
76
+ //选中元素显示,默认true
77
+ animation: !1,
78
+ timeline: !1,
79
+ //时间线,默认true
80
+ geocoder: !1,
81
+ //地名查找,默认true
82
+ homeButton: !1,
83
+ //控制右上角home按钮显示
84
+ baseLayerPicker: !1,
85
+ //地图切换控件(底图以及地形图)是否显示,默认显示true
86
+ imageryProvider: new i.GridImageryProvider(),
87
+ sceneModePicker: !1,
88
+ navigationHelpButton: !1,
89
+ infoBox: !1,
90
+ //点击要素之后显示的信息,默认true
91
+ fullscreenButton: !1,
92
+ //全屏按钮,默认显示true
93
+ shouldAnimate: !0,
94
+ // Enable animations
95
+ terrainProvider: e,
96
+ contextOptions: {
97
+ webgl: {
98
+ preserveDrawingBuffer: !0
99
+ //允许截图
100
+ }
101
+ }
102
+ });
103
+ return o._cesiumWidget._creditContainer.style.display = "none", o;
104
+ }
105
+ function f(r, a) {
106
+ g(r, a);
107
+ }
108
+ function v(r, a, e) {
109
+ console.log("添加标记", r, a, e);
110
+ }
111
+ function p(r, a) {
112
+ const e = y(r);
113
+ return f(e, a), {
114
+ instance: e,
115
+ addMarker: (o, s) => v(e, o, s)
116
+ };
117
+ }
118
+ export {
119
+ p as useMap
120
+ };
File without changes
File without changes
package/dist/3d.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './3d/index'
2
+ export {}
@@ -0,0 +1,2 @@
1
+ export declare const version = "1.0.0";
2
+ export declare const author = "zhangjianfeng";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.0.0",o="zhangjianfeng";exports.author=o;exports.version=e;
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ const n = "1.0.0", o = "zhangjianfeng";
2
+ export {
3
+ o as author,
4
+ n as version
5
+ };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "jgis",
3
+ "version": "1.0.0",
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
+ }