jgis 1.0.1 → 1.0.3
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.
- package/README.md +119 -16
- package/dist/2d/index.d.ts +1 -1
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +347 -286
- package/dist/2d/layer.d.ts +21 -2
- package/dist/2d/types.d.ts +16 -6
- package/dist/2d/utils.d.ts +5 -2
- package/dist/3d/core.d.ts +39 -8
- package/dist/3d/index.d.ts +20 -4
- package/dist/3d/index.js +1 -1
- package/dist/3d/index.mjs +251 -77
- package/dist/3d/interaction.d.ts +5 -0
- package/dist/3d/layer.d.ts +29 -0
- package/dist/3d/store.d.ts +16 -0
- package/dist/3d/types.d.ts +56 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +7 -3
- package/dist/utils/index.d.ts +0 -0
- package/package.json +1 -1
- package/dist/2d/index2.d.ts +0 -23
package/dist/2d/layer.d.ts
CHANGED
|
@@ -60,11 +60,30 @@ export declare function createVectorLayer(layerName: string, data: any[], Map: M
|
|
|
60
60
|
* @returns {TileLayer} 矢量图层
|
|
61
61
|
*/
|
|
62
62
|
export declare function createBufferCircle(layerName: string, data: any, Map: MapInstance, options: LayerOptions): VectorLayer;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* 创建Overlay图层
|
|
65
|
+
* @param layerName 图层名称
|
|
66
|
+
* @param Map 地图实例
|
|
67
|
+
* @param options 图层配置
|
|
68
|
+
* @returns OverlayResult
|
|
69
|
+
*/
|
|
70
|
+
export declare function createOverlayLayer(layerName: string, Map: MapInstance, options: LayerOptions): OverlayResult;
|
|
71
|
+
/**
|
|
72
|
+
* 创建空白图层
|
|
73
|
+
* @param layerName 图层名
|
|
74
|
+
* @param options 配置项
|
|
75
|
+
* @returns VectorLayer
|
|
76
|
+
*/
|
|
77
|
+
export declare function createBlankLayer(map: Map, layerName: string, options: LayerOptions): VectorLayer;
|
|
65
78
|
/**
|
|
66
79
|
* 根据图层名称获取图层
|
|
67
80
|
* @param map 地图实例
|
|
68
81
|
* @param layerName 图层名称
|
|
69
82
|
*/
|
|
70
83
|
export declare function getLayerByName(map: Map, layerName: string): any;
|
|
84
|
+
/**
|
|
85
|
+
* 根据图层名称获取图层
|
|
86
|
+
* @param map 地图实例
|
|
87
|
+
* @param layerName 图层名称
|
|
88
|
+
*/
|
|
89
|
+
export declare function visibleLayer(map: Map, layerName: string, visible: boolean): Layer;
|
package/dist/2d/types.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { StyleLike, default as Style } from 'ol/style/Style';
|
|
|
3
3
|
import { Layer } from 'ol/layer';
|
|
4
4
|
import { FeatureLike } from 'ol/Feature';
|
|
5
5
|
import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
|
|
6
|
+
import { Source } from 'ol/source';
|
|
7
|
+
import { Projection } from 'ol/proj';
|
|
6
8
|
export interface BaseLayerOptions {
|
|
7
9
|
token?: string;
|
|
8
10
|
maxZoom?: number;
|
|
@@ -66,15 +68,23 @@ export interface MapContext {
|
|
|
66
68
|
addMarker: (layerName: string, data: any, options?: LayerOptions) => void;
|
|
67
69
|
createLayer: (layerName: string, data: any, options?: LayerOptions) => Layer;
|
|
68
70
|
removeLayer: (layerName: string) => void;
|
|
71
|
+
visibleLayer: (layerName: string, visible: boolean) => Layer;
|
|
72
|
+
getLayerByName: (layerName: string) => Layer;
|
|
73
|
+
getSourceByName: (layerName: string) => Source;
|
|
74
|
+
getLonLat: (data: any) => [number, number];
|
|
75
|
+
createBlankLayer: (layerName: string, options: LayerOptions) => Layer;
|
|
76
|
+
lightFeature: (layerName: string, feature: FeatureLike, options: HighLightOptions, zoomFlag: boolean) => void;
|
|
77
|
+
flashFeature: (layerName: string, feature: FeatureLike & customFeature, options: FlashOptions) => void;
|
|
78
|
+
queryFeature: (layerName: string, properties: any) => FeatureLike;
|
|
69
79
|
useSelect: (options: SelectOptions) => UseSelectResult;
|
|
70
80
|
useHover: (options: HoverOptions) => UseHoverResult;
|
|
71
|
-
flyTo: (coordinate: [number, number], options: flyOptions) =>
|
|
72
|
-
flyToByExtent: (options: flyOptions) =>
|
|
73
|
-
flyToByFeature: (feature: Feature, options: flyOptions) =>
|
|
74
|
-
getProjection: () =>
|
|
81
|
+
flyTo: (coordinate: [number, number], options: flyOptions) => Promise<boolean>;
|
|
82
|
+
flyToByExtent: (options: flyOptions) => Promise<boolean>;
|
|
83
|
+
flyToByFeature: (feature: Feature, options: flyOptions) => Promise<boolean>;
|
|
84
|
+
getProjection: () => Projection;
|
|
75
85
|
getZoom: () => number;
|
|
76
86
|
setZoom: (zoom: number) => void;
|
|
77
87
|
getMapContext: (id: string) => Promise<MapContext>;
|
|
78
|
-
onMapReady: (id: string, callback: () => void) => void;
|
|
79
|
-
destroyMap: (id: string) => void;
|
|
88
|
+
onMapReady: (id: string, callback: (ctx: MapContext) => void) => void;
|
|
89
|
+
destroyMap: (map: MapInstance, id: string) => void;
|
|
80
90
|
}
|
package/dist/2d/utils.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ type dataType = {
|
|
|
19
19
|
* @param data 数据
|
|
20
20
|
* @returns [经度, 纬度]
|
|
21
21
|
*/
|
|
22
|
-
export declare function getLonLat(data: dataType
|
|
22
|
+
export declare function getLonLat(data: dataType, options?: {
|
|
23
|
+
lonLabel: string;
|
|
24
|
+
latLabel: string;
|
|
25
|
+
}): [number, number];
|
|
23
26
|
/**
|
|
24
27
|
* 根据图层名称删除图层
|
|
25
28
|
* @param map 地图实例
|
|
@@ -47,7 +50,7 @@ export declare function flashFeature(layerName: string, feature: FeatureLike & c
|
|
|
47
50
|
* @param properties 数据
|
|
48
51
|
* @returns Feature 要素
|
|
49
52
|
*/
|
|
50
|
-
export declare function
|
|
53
|
+
export declare function queryFeature(map: Map, layerName: string, properties: any): FeatureLike;
|
|
51
54
|
export declare function getSelectedFtByEvt(event: any): {
|
|
52
55
|
layerName?: string;
|
|
53
56
|
feature?: FeatureLike;
|
package/dist/3d/core.d.ts
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
|
+
import { Coordinates, flyOptions } from './types';
|
|
1
2
|
import * as Cesium from 'cesium';
|
|
2
3
|
/**
|
|
3
4
|
* 创建Viewer
|
|
4
5
|
*
|
|
5
|
-
* @param {String} [
|
|
6
|
+
* @param {String} [el] Cesium.viewer对应的DOM元素名:<div id="cesiumContainer"></div>
|
|
6
7
|
* @param {String} [terrainUrl] 地形链接
|
|
7
8
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
/**
|
|
10
|
-
* 初始化地图
|
|
11
|
-
* @param {Cesium.Viewer} viewer
|
|
12
|
-
*/
|
|
13
|
-
export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): void;
|
|
9
|
+
export declare function createViewer(el: string, options?: any): Cesium.Viewer;
|
|
14
10
|
/**
|
|
15
11
|
* 添加标记
|
|
16
12
|
* @param {Cesium.Viewer} viewer
|
|
13
|
+
* @param {stringr} layerName
|
|
14
|
+
* @param points 数据
|
|
17
15
|
* @returns {void}
|
|
18
16
|
*/
|
|
19
|
-
export declare function addMarker(viewer: Cesium.Viewer, points: any[],
|
|
17
|
+
export declare function addMarker(viewer: Cesium.Viewer, layerName: string, points: any[], options: any): void;
|
|
18
|
+
/**
|
|
19
|
+
* 定位
|
|
20
|
+
* @param map 地图实例
|
|
21
|
+
* @param coordinate [经度, 纬度]
|
|
22
|
+
* @param options {flyOptions} 配置项
|
|
23
|
+
*/
|
|
24
|
+
export declare function flyTo(viewer: Cesium.Viewer, coordinate: Coordinates, options?: flyOptions): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* 飞行到初始位置
|
|
27
|
+
* @param viewer 视图对象
|
|
28
|
+
* @param duration 飞行时间
|
|
29
|
+
*/
|
|
30
|
+
export declare function flyHome(viewer: Cesium.Viewer, duration?: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* 飞行到包围球
|
|
33
|
+
* @param viewer 视图对象
|
|
34
|
+
* @param boundingSphere
|
|
35
|
+
* @param options 配置项
|
|
36
|
+
*/
|
|
37
|
+
export declare function flyToBoundingSphere(viewer: Cesium.Viewer, boundingSphere: Cesium.BoundingSphere, options: flyOptions): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* 设置视角
|
|
40
|
+
* @param viewer 视图对象
|
|
41
|
+
* @param coordinate [经度, 纬度, 高度]
|
|
42
|
+
* @param options 配置项
|
|
43
|
+
*/
|
|
44
|
+
export declare function setView(viewer: Cesium.Viewer, coordinate: Coordinates, options: flyOptions): void;
|
|
45
|
+
/**
|
|
46
|
+
* 销毁地图
|
|
47
|
+
* @param viewer 视图对象
|
|
48
|
+
* @param id 地图id
|
|
49
|
+
*/
|
|
50
|
+
export declare function destroyMap(viewer: Cesium.Viewer, id: string): void;
|
package/dist/3d/index.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { MapContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 创建地图
|
|
4
|
+
* @param el 绑定地图元素Id
|
|
5
|
+
* @param options 配置项
|
|
6
|
+
* @returns 地图方法和地图实例
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMap(el: string, options: any): MapContext;
|
|
9
|
+
/**
|
|
10
|
+
* 保证能获取到方法
|
|
11
|
+
* @param id
|
|
12
|
+
* @param callback
|
|
13
|
+
*/
|
|
14
|
+
export declare function onMapReady(id: string, callback: (ctx: MapContext) => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* 获取地图返回的上下文
|
|
17
|
+
* @param id
|
|
18
|
+
* @returns Promise<MapContext>
|
|
19
|
+
*/
|
|
20
|
+
export declare function getMapContext(id: string): Promise<MapContext>;
|
package/dist/3d/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var M=Object.defineProperty,C=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var p=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var h=(t,r,e)=>r in t?M(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,u=(t,r)=>{for(var e in r||(r={}))x.call(r,e)&&h(t,e,r[e]);if(p)for(var e of p(r))O.call(r,e)&&h(t,e,r[e]);return t},f=(t,r)=>C(t,I(r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("cesium"),b=require("../index.js");function k(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,a.get?a:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const o=k(L);function _(t,r){const e={baseType:"img",noteType:"cia",token:"dadcbbdb5206b626a29ca739686b3087"},{baseType:a,noteType:n,token:i}=Object.assign(e,r),c="https://t{s}.tianditu.gov.cn",s=["0","1","2","3","4","5","6","7"],l=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});let d=t.imageryLayers.addImageryProvider(l);d.gamma=1;const T=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(T);const v=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(v)}function D(t,r){_(t,r)}function P(t,r,e,a){(!a||!a.type)&&(a=Object.assign({},e,a));const n=a.type||"Point";let i;switch(n){case"Point":i=B(t,r,e,a);break;case"LineString":i=R(t,r,e,a);break}return i}function B(t,r,e,a){const n=t.scene.primitives.add(new o.BillboardCollection);return n._layerName=r,e.forEach((i,c)=>{const s={scale:1,verticalOrigin:o.VerticalOrigin.BOTTOM,show:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new o.NearFarScalar(1,1,1e5,.2)},l={position:o.Cartesian3.fromDegrees(...b.getLonLat(i),1),image:a.style||a.getStyle(i),id:i.id||`point_${c}`},d=n.add(u(u(u({},s),a),l));d._originStyle=f(u(u(u({},s),a),l),{color:o.Color.WHITE}),d.properties=i}),t.scene.requestRender(),n}function R(t,r,e,a){if(e.length<2)return;const n=E(e,a),i=new o.GroundPolylinePrimitive({geometryInstances:n,appearance:new o.PolylineColorAppearance({translucent:!0}),interleave:!0,allowPicking:!0,asynchronous:!1});i._layerName=r,t.scene.groundPrimitives.add(i)}function E(t,r){const e=[],a=t.map(c=>o.Cartesian3.fromDegrees(...b.getLonLat(c),0)),n=new o.GroundPolylineGeometry({positions:a,width:r.width||4,granularity:r.granularity||2e3}),i=new o.GeometryInstance({id:"pipeLine",geometry:n,attributes:{color:o.ColorGeometryInstanceAttribute.fromColor(o.Color.fromCssColorString(r.color))}});return e.push(i),e}function N(t,r){const e=t.scene.primitives,a=e.length;for(let n=0;n<a;n++){const i=e.get(n);if(i._layerName===r)return i}return null}const y=new Map,m={},g={},j=(t,r)=>{y.has(t)&&console.warn(`Map with target '${t}' already exists. Overwriting...`),y.set(t,r),m[t]&&(m[t].forEach(e=>e(r)),delete m[t]),g[t]&&(g[t].forEach(e=>e(r)),delete g[t])};function w(t){const r=y.get(t);return r?Promise.resolve(r):new Promise(e=>{g[t]=g[t]||[],g[t].push(e)})}const $=t=>{y.has(t)&&(y.delete(t),delete m[t])},S=(t,r)=>{const e=y.get(t);if(e){r(e);return}m[t]||(m[t]=[]),m[t].push(r)};function H(t,r={}){const e=new o.Viewer(t,{requestRenderMode:!0,maximumRenderTimeChange:1/0,selectionIndicator:!1,animation:!1,timeline:!1,geocoder:!1,homeButton:!1,baseLayerPicker:!1,sceneModePicker:!1,navigationHelpButton:!1,infoBox:!1,fullscreenButton:!1,shouldAnimate:!0,contextOptions:{webgl:{preserveDrawingBuffer:!0}}});let a;return o.defined(r.terrainUrl)?o.CesiumTerrainProvider.fromUrl(r.terrainUrl,{requestVertexNormals:!0,requestWaterMask:!0}).then(n=>{a=n,e.terrainProvider=a}):a=new o.EllipsoidTerrainProvider,e.terrainProvider=a,e._cesiumWidget._creditContainer.style.display="none",e.scene.globe.baseColor=new o.Color(0,0,0,0),e.scene.screenSpaceCameraController.minimumZoomDistance=r.minZoom||1,e.scene.screenSpaceCameraController.maximumZoomDistance=r.maxZoom||1e7,e.resolutionScale=window.devicePixelRatio>2?2:window.devicePixelRatio,e}function q(t,r,e,a){P(t,r,e,f(u({},a),{type:"Point"}))}function V(t,r,e){return new Promise((a,n)=>{t.camera.flyTo({destination:o.Cartesian3.fromDegrees(...r),duration:e.duration||1.2,orientation:{heading:e.heading||0,pitch:e.pitch||-Math.PI/2,roll:e.roll||0},easingFunction:e.easing||o.EasingFunction.LINEAR_NONE,maximumHeight:e.maxHeight||1e6,complete:()=>{a(!0)},cancel:()=>{a(!1)}})})}function G(t,r=1){return t.camera.flyHome(r)}function U(t,r,e){return new Promise((a,n)=>{t.camera.flyToBoundingSphere(r,{duration:e.duration||1e3,offset:new o.HeadingPitchRange(e.heading||0,e.pitch||-Math.PI/4,e.roll||0),easingFunction:e.easing,maximumHeight:e.maxHeight||1e6,complete:()=>{a(!0)},cancel:()=>{a(!1)}})})}function F(t,r,e){t.camera.setView({destination:o.Cartesian3.fromDegrees(...r),orientation:{heading:e.heading||0,pitch:e.pitch||-Math.PI/2,roll:e.roll||0}})}function W(t,r){t.destroy(),$(r)}function A(t,r){const e=new Set,a=new o.ScreenSpaceEventHandler(t.scene.canvas);let n=null;a.setInputAction(c=>{const s=t.scene.pick(c.position);if(n&&(Object.assign(n,n._originStyle),n=null,t.scene.requestRender()),o.defined(s)&&s.primitive instanceof o.Billboard){const l=s.primitive,d={billboard:l,properties:l.properties,event:c,pick:s};n=l,i(d),Object.assign(l,r.style||r.getStyle(l)),t.scene.requestRender()}},o.ScreenSpaceEventType.LEFT_CLICK);const i=c=>e.forEach(s=>s(c));return{onSelect:c=>(e.add(c),()=>e.delete(c)),clear(){e.clear()},destroy(){e.clear()}}}function z(t,r){const e=H(t,r);D(e,r);const a={targetId:t,instance:e,addMarker:(n,i,c)=>q(e,n,i,c),createLayer:(n,i,c)=>P(e,n,i,c),getLayerByName:n=>N(e,n),useSelect:n=>A(e,n),flyTo:(n,i)=>V(e,n,i),flyHome:n=>G(e,n),flyToBoundingSphere:(n,i)=>U(e,n,i),setView:(n,i)=>F(e,n,i),getMapContext:n=>w(n),onMapReady:(n,i)=>S(n,i),destroyMap:n=>W(e,n)};return j(t,a),a}function Z(t,r){S(t,r)}function K(t){return w(t)}exports.getMapContext=K;exports.onMapReady=Z;exports.useMap=z;
|
package/dist/3d/index.mjs
CHANGED
|
@@ -1,73 +1,138 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
import * as i from "cesium";
|
|
18
|
-
function g(r, a) {
|
|
1
|
+
var C = Object.defineProperty, M = Object.defineProperties;
|
|
2
|
+
var I = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var p = Object.getOwnPropertySymbols;
|
|
4
|
+
var x = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var h = (r, t, e) => t in r ? C(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, u = (r, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
x.call(t, e) && h(r, e, t[e]);
|
|
8
|
+
if (p)
|
|
9
|
+
for (var e of p(t))
|
|
10
|
+
k.call(t, e) && h(r, e, t[e]);
|
|
11
|
+
return r;
|
|
12
|
+
}, f = (r, t) => M(r, I(t));
|
|
13
|
+
import * as o from "cesium";
|
|
14
|
+
import { getLonLat as w } from "../index.mjs";
|
|
15
|
+
function L(r, t) {
|
|
19
16
|
const e = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
cia_w: !0,
|
|
17
|
+
baseType: "img",
|
|
18
|
+
noteType: "cia",
|
|
23
19
|
token: "dadcbbdb5206b626a29ca739686b3087"
|
|
24
|
-
}, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
20
|
+
}, { baseType: a, noteType: n, token: i } = Object.assign(e, t), c = "https://t{s}.tianditu.gov.cn", s = ["0", "1", "2", "3", "4", "5", "6", "7"], l = new o.UrlTemplateImageryProvider({
|
|
21
|
+
url: `${c}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
22
|
+
subdomains: s,
|
|
23
|
+
tilingScheme: new o.WebMercatorTilingScheme()
|
|
24
|
+
});
|
|
25
|
+
let d = r.imageryLayers.addImageryProvider(l);
|
|
26
|
+
d.gamma = 1;
|
|
27
|
+
const S = new o.UrlTemplateImageryProvider({
|
|
28
|
+
url: `${c}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
29
|
+
subdomains: s,
|
|
30
|
+
tilingScheme: new o.WebMercatorTilingScheme()
|
|
31
|
+
});
|
|
32
|
+
r.imageryLayers.addImageryProvider(S);
|
|
33
|
+
const v = new o.UrlTemplateImageryProvider({
|
|
34
|
+
url: `${c}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
35
|
+
subdomains: s,
|
|
36
|
+
tilingScheme: new o.WebMercatorTilingScheme()
|
|
37
|
+
// maximumLevel: 18
|
|
38
|
+
});
|
|
39
|
+
r.imageryLayers.addImageryProvider(v);
|
|
40
|
+
}
|
|
41
|
+
function O(r, t) {
|
|
42
|
+
L(r, t);
|
|
43
|
+
}
|
|
44
|
+
function P(r, t, e, a) {
|
|
45
|
+
(!a || !a.type) && (a = Object.assign({}, e, a));
|
|
46
|
+
const n = a.type || "Point";
|
|
47
|
+
let i;
|
|
48
|
+
switch (n) {
|
|
49
|
+
case "Point":
|
|
50
|
+
i = B(r, t, e, a);
|
|
51
|
+
break;
|
|
52
|
+
case "LineString":
|
|
53
|
+
i = _(r, t, e, a);
|
|
54
|
+
break;
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
function B(r, t, e, a) {
|
|
59
|
+
const n = r.scene.primitives.add(new o.BillboardCollection());
|
|
60
|
+
return n._layerName = t, e.forEach((i, c) => {
|
|
61
|
+
const s = {
|
|
62
|
+
scale: 1,
|
|
63
|
+
// 缩放比例
|
|
64
|
+
verticalOrigin: o.VerticalOrigin.BOTTOM,
|
|
65
|
+
// 以底部为定位中心
|
|
66
|
+
show: !0,
|
|
67
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
68
|
+
// 禁止深度测试距离
|
|
69
|
+
scaleByDistance: new o.NearFarScalar(1, 1, 1e5, 0.2)
|
|
70
|
+
// 根据相机距离缩放
|
|
71
|
+
}, l = {
|
|
72
|
+
position: o.Cartesian3.fromDegrees(...w(i), 1),
|
|
73
|
+
image: a.style || a.getStyle(i),
|
|
74
|
+
id: i.id || `point_${c}`
|
|
75
|
+
}, d = n.add(u(u(u({}, s), a), l));
|
|
76
|
+
d._originStyle = f(u(u(u({}, s), a), l), { color: o.Color.WHITE }), d.properties = i;
|
|
77
|
+
}), r.scene.requestRender(), n;
|
|
78
|
+
}
|
|
79
|
+
function _(r, t, e, a) {
|
|
80
|
+
if (e.length < 2) return;
|
|
81
|
+
const n = D(e, a), i = new o.GroundPolylinePrimitive({
|
|
82
|
+
geometryInstances: n,
|
|
83
|
+
appearance: new o.PolylineColorAppearance({
|
|
84
|
+
translucent: !0
|
|
85
|
+
}),
|
|
86
|
+
interleave: !0,
|
|
87
|
+
allowPicking: !0,
|
|
88
|
+
asynchronous: !1
|
|
89
|
+
});
|
|
90
|
+
i._layerName = t, r.scene.groundPrimitives.add(i);
|
|
91
|
+
}
|
|
92
|
+
function D(r, t) {
|
|
93
|
+
const e = [], a = r.map((c) => o.Cartesian3.fromDegrees(...w(c), 0)), n = new o.GroundPolylineGeometry({
|
|
94
|
+
positions: a,
|
|
95
|
+
width: t.width || 4,
|
|
96
|
+
granularity: t.granularity || 2e3
|
|
97
|
+
}), i = new o.GeometryInstance({
|
|
98
|
+
id: "pipeLine",
|
|
99
|
+
geometry: n,
|
|
100
|
+
attributes: {
|
|
101
|
+
color: o.ColorGeometryInstanceAttribute.fromColor(o.Color.fromCssColorString(t.color))
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return e.push(i), e;
|
|
105
|
+
}
|
|
106
|
+
function E(r, t) {
|
|
107
|
+
const e = r.scene.primitives, a = e.length;
|
|
108
|
+
for (let n = 0; n < a; n++) {
|
|
109
|
+
const i = e.get(n);
|
|
110
|
+
if (i._layerName === t)
|
|
111
|
+
return i;
|
|
60
112
|
}
|
|
113
|
+
return null;
|
|
61
114
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
|
|
115
|
+
const y = /* @__PURE__ */ new Map(), m = {}, g = {}, R = (r, t) => {
|
|
116
|
+
y.has(r) && console.warn(`Map with target '${r}' already exists. Overwriting...`), y.set(r, t), m[r] && (m[r].forEach((e) => e(t)), delete m[r]), g[r] && (g[r].forEach((e) => e(t)), delete g[r]);
|
|
117
|
+
};
|
|
118
|
+
function b(r) {
|
|
119
|
+
const t = y.get(r);
|
|
120
|
+
return t ? Promise.resolve(t) : new Promise((e) => {
|
|
121
|
+
g[r] = g[r] || [], g[r].push(e);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const N = (r) => {
|
|
125
|
+
y.has(r) && (y.delete(r), delete m[r]);
|
|
126
|
+
}, T = (r, t) => {
|
|
127
|
+
const e = y.get(r);
|
|
128
|
+
if (e) {
|
|
129
|
+
t(e);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
m[r] || (m[r] = []), m[r].push(t);
|
|
133
|
+
};
|
|
134
|
+
function $(r, t = {}) {
|
|
135
|
+
const e = new o.Viewer(r, {
|
|
71
136
|
requestRenderMode: !0,
|
|
72
137
|
//减少应用程序的 CPU/GPU 使用率
|
|
73
138
|
maximumRenderTimeChange: 1 / 0,
|
|
@@ -83,7 +148,7 @@ function y(r, a) {
|
|
|
83
148
|
//控制右上角home按钮显示
|
|
84
149
|
baseLayerPicker: !1,
|
|
85
150
|
//地图切换控件(底图以及地形图)是否显示,默认显示true
|
|
86
|
-
imageryProvider: new
|
|
151
|
+
// imageryProvider: new Cesium.GridImageryProvider({}),
|
|
87
152
|
sceneModePicker: !1,
|
|
88
153
|
navigationHelpButton: !1,
|
|
89
154
|
infoBox: !1,
|
|
@@ -92,7 +157,7 @@ function y(r, a) {
|
|
|
92
157
|
//全屏按钮,默认显示true
|
|
93
158
|
shouldAnimate: !0,
|
|
94
159
|
// Enable animations
|
|
95
|
-
terrainProvider:
|
|
160
|
+
// terrainProvider: _terrainProvider, //地形
|
|
96
161
|
contextOptions: {
|
|
97
162
|
webgl: {
|
|
98
163
|
preserveDrawingBuffer: !0
|
|
@@ -100,21 +165,130 @@ function y(r, a) {
|
|
|
100
165
|
}
|
|
101
166
|
}
|
|
102
167
|
});
|
|
103
|
-
|
|
168
|
+
let a;
|
|
169
|
+
return o.defined(t.terrainUrl) ? o.CesiumTerrainProvider.fromUrl(t.terrainUrl, {
|
|
170
|
+
requestVertexNormals: !0,
|
|
171
|
+
requestWaterMask: !0
|
|
172
|
+
}).then((n) => {
|
|
173
|
+
a = n, e.terrainProvider = a;
|
|
174
|
+
}) : a = new o.EllipsoidTerrainProvider(), e.terrainProvider = a, e._cesiumWidget._creditContainer.style.display = "none", e.scene.globe.baseColor = new o.Color(0, 0, 0, 0), e.scene.screenSpaceCameraController.minimumZoomDistance = t.minZoom || 1, e.scene.screenSpaceCameraController.maximumZoomDistance = t.maxZoom || 1e7, e.resolutionScale = window.devicePixelRatio > 2 ? 2 : window.devicePixelRatio, e;
|
|
104
175
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
176
|
+
function H(r, t, e, a) {
|
|
177
|
+
P(r, t, e, f(u({}, a), { type: "Point" }));
|
|
107
178
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
179
|
+
function V(r, t, e) {
|
|
180
|
+
return new Promise((a, n) => {
|
|
181
|
+
r.camera.flyTo({
|
|
182
|
+
destination: o.Cartesian3.fromDegrees(...t),
|
|
183
|
+
duration: e.duration || 1.2,
|
|
184
|
+
// 飞行动画时间(秒)
|
|
185
|
+
orientation: {
|
|
186
|
+
heading: e.heading || 0,
|
|
187
|
+
pitch: e.pitch || -Math.PI / 2,
|
|
188
|
+
roll: e.roll || 0
|
|
189
|
+
},
|
|
190
|
+
easingFunction: e.easing || o.EasingFunction.LINEAR_NONE,
|
|
191
|
+
// 飞行动画缓动函数
|
|
192
|
+
maximumHeight: e.maxHeight || 1e6,
|
|
193
|
+
// 相机最大飞行高度
|
|
194
|
+
complete: () => {
|
|
195
|
+
a(!0);
|
|
196
|
+
},
|
|
197
|
+
cancel: () => {
|
|
198
|
+
a(!1);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function j(r, t = 1) {
|
|
204
|
+
return r.camera.flyHome(t);
|
|
205
|
+
}
|
|
206
|
+
function G(r, t, e) {
|
|
207
|
+
return new Promise((a, n) => {
|
|
208
|
+
r.camera.flyToBoundingSphere(t, {
|
|
209
|
+
duration: e.duration || 1e3,
|
|
210
|
+
// 飞行动画时间(秒)
|
|
211
|
+
offset: new o.HeadingPitchRange(e.heading || 0, e.pitch || -Math.PI / 4, e.roll || 0),
|
|
212
|
+
easingFunction: e.easing,
|
|
213
|
+
// 飞行动画缓动函数
|
|
214
|
+
maximumHeight: e.maxHeight || 1e6,
|
|
215
|
+
// 相机最大飞行高度
|
|
216
|
+
complete: () => {
|
|
217
|
+
a(!0);
|
|
218
|
+
},
|
|
219
|
+
cancel: () => {
|
|
220
|
+
a(!1);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
110
224
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
225
|
+
function U(r, t, e) {
|
|
226
|
+
r.camera.setView({
|
|
227
|
+
destination: o.Cartesian3.fromDegrees(...t),
|
|
228
|
+
orientation: {
|
|
229
|
+
heading: e.heading || 0,
|
|
230
|
+
pitch: e.pitch || -Math.PI / 2,
|
|
231
|
+
roll: e.roll || 0
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function q(r, t) {
|
|
236
|
+
r.destroy(), N(t);
|
|
237
|
+
}
|
|
238
|
+
function F(r, t) {
|
|
239
|
+
const e = /* @__PURE__ */ new Set(), a = new o.ScreenSpaceEventHandler(r.scene.canvas);
|
|
240
|
+
let n = null;
|
|
241
|
+
a.setInputAction((c) => {
|
|
242
|
+
const s = r.scene.pick(c.position);
|
|
243
|
+
if (n && (Object.assign(n, n._originStyle), n = null, r.scene.requestRender()), o.defined(s) && s.primitive instanceof o.Billboard) {
|
|
244
|
+
const l = s.primitive, d = {
|
|
245
|
+
billboard: l,
|
|
246
|
+
properties: l.properties,
|
|
247
|
+
event: c,
|
|
248
|
+
pick: s
|
|
249
|
+
};
|
|
250
|
+
n = l, i(d), Object.assign(l, t.style || t.getStyle(l)), r.scene.requestRender();
|
|
251
|
+
}
|
|
252
|
+
}, o.ScreenSpaceEventType.LEFT_CLICK);
|
|
253
|
+
const i = (c) => e.forEach((s) => s(c));
|
|
254
|
+
return {
|
|
255
|
+
onSelect: (c) => (e.add(c), () => e.delete(c)),
|
|
256
|
+
clear() {
|
|
257
|
+
e.clear();
|
|
258
|
+
},
|
|
259
|
+
destroy() {
|
|
260
|
+
e.clear();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function Z(r, t) {
|
|
265
|
+
const e = $(r, t);
|
|
266
|
+
O(e, t);
|
|
267
|
+
const a = {
|
|
268
|
+
targetId: r,
|
|
114
269
|
instance: e,
|
|
115
|
-
addMarker: (
|
|
270
|
+
addMarker: (n, i, c) => H(e, n, i, c),
|
|
271
|
+
createLayer: (n, i, c) => P(e, n, i, c),
|
|
272
|
+
getLayerByName: (n) => E(e, n),
|
|
273
|
+
useSelect: (n) => F(e, n),
|
|
274
|
+
flyTo: (n, i) => V(e, n, i),
|
|
275
|
+
flyHome: (n) => j(e, n),
|
|
276
|
+
flyToBoundingSphere: (n, i) => G(e, n, i),
|
|
277
|
+
setView: (n, i) => U(e, n, i),
|
|
278
|
+
getMapContext: (n) => b(n),
|
|
279
|
+
onMapReady: (n, i) => T(n, i),
|
|
280
|
+
destroyMap: (n) => q(e, n)
|
|
116
281
|
};
|
|
282
|
+
return R(r, a), a;
|
|
283
|
+
}
|
|
284
|
+
function z(r, t) {
|
|
285
|
+
T(r, t);
|
|
286
|
+
}
|
|
287
|
+
function K(r) {
|
|
288
|
+
return b(r);
|
|
117
289
|
}
|
|
118
290
|
export {
|
|
119
|
-
|
|
291
|
+
K as getMapContext,
|
|
292
|
+
z as onMapReady,
|
|
293
|
+
Z as useMap
|
|
120
294
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
/**
|
|
3
|
+
* 初始化地图
|
|
4
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
5
|
+
* @param {any} options 配置项
|
|
6
|
+
*/
|
|
7
|
+
export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* 创建图层
|
|
10
|
+
* @param {Cesium.Viewer} viewer {Map} 地图
|
|
11
|
+
* @param {string} layerName 图层名称
|
|
12
|
+
* @param {any} data 数据
|
|
13
|
+
* @param options 配置项
|
|
14
|
+
* @returns 图层
|
|
15
|
+
*/
|
|
16
|
+
export declare function createLayer(viewer: Cesium.Viewer, layerName: string, data: any, options: any): any;
|
|
17
|
+
/**
|
|
18
|
+
* 创建点图层
|
|
19
|
+
* @param viewer 视图
|
|
20
|
+
* @param layerName 图层名称
|
|
21
|
+
* @param data 数据
|
|
22
|
+
* @param options 配置项
|
|
23
|
+
*/
|
|
24
|
+
export declare function createPointLayer(viewer: Cesium.Viewer, layerName: string, data: any[], options: Cesium.Billboard.ConstructorOptions & {
|
|
25
|
+
style?: any;
|
|
26
|
+
getStyle?: (item: any) => any;
|
|
27
|
+
}): any;
|
|
28
|
+
export declare function createLineLayer(viewer: any, layerName: string, data: any[], options: any): void;
|
|
29
|
+
export declare function getLayerByName(viewer: any, layerName: any): 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;
|