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.
- package/README.md +164 -18
- package/dist/2d/index.d.ts +1 -1
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +157 -151
- package/dist/2d/interaction.d.ts +2 -2
- package/dist/2d/types.d.ts +9 -8
- package/dist/2d/utils.d.ts +4 -1
- 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 +321 -78
- package/dist/3d/interaction.d.ts +47 -0
- package/dist/3d/layer.d.ts +71 -0
- package/dist/3d/store.d.ts +16 -0
- package/dist/3d/types.d.ts +68 -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 +7 -0
- package/package.json +70 -70
- package/dist/2d/index2.d.ts +0 -23
package/dist/2d/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Layer } from 'ol/layer';
|
|
|
4
4
|
import { FeatureLike } from 'ol/Feature';
|
|
5
5
|
import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
|
|
6
6
|
import { Source } from 'ol/source';
|
|
7
|
+
import { Projection } from 'ol/proj';
|
|
7
8
|
export interface BaseLayerOptions {
|
|
8
9
|
token?: string;
|
|
9
10
|
maxZoom?: number;
|
|
@@ -75,15 +76,15 @@ export interface MapContext {
|
|
|
75
76
|
lightFeature: (layerName: string, feature: FeatureLike, options: HighLightOptions, zoomFlag: boolean) => void;
|
|
76
77
|
flashFeature: (layerName: string, feature: FeatureLike & customFeature, options: FlashOptions) => void;
|
|
77
78
|
queryFeature: (layerName: string, properties: any) => FeatureLike;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
flyTo: (coordinate: [number, number], options: flyOptions) =>
|
|
81
|
-
flyToByExtent: (options: flyOptions) =>
|
|
82
|
-
flyToByFeature: (feature: Feature, options: flyOptions) =>
|
|
83
|
-
getProjection: () =>
|
|
79
|
+
createSelect: (options: SelectOptions) => UseSelectResult;
|
|
80
|
+
createHover: (options: HoverOptions) => UseHoverResult;
|
|
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;
|
|
84
85
|
getZoom: () => number;
|
|
85
86
|
setZoom: (zoom: number) => void;
|
|
86
87
|
getMapContext: (id: string) => Promise<MapContext>;
|
|
87
|
-
onMapReady: (id: string, callback: () => void) => void;
|
|
88
|
-
destroyMap: (id: string) => void;
|
|
88
|
+
onMapReady: (id: string, callback: (ctx: MapContext) => void) => void;
|
|
89
|
+
destroyMap: (map: MapInstance, id: string) => void;
|
|
89
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 地图实例
|
package/dist/3d/core.d.ts
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
|
+
import { Coordinates, flyOptions, optionsMap } 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: optionsMap['Point']): 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 C=Object.defineProperty,L=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var b=(t,r,e)=>r in t?C(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,m=(t,r)=>{for(var e in r||(r={}))k.call(r,e)&&b(t,e,r[e]);if(v)for(var e of v(r))O.call(r,e)&&b(t,e,r[e]);return t},p=(t,r)=>L(t,I(r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("cesium"),P=require("../index.js");function _(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 c=_(x);function B(t,r){const e={baseType:"img",noteType:"cia",token:"dadcbbdb5206b626a29ca739686b3087"},{baseType:a,noteType:n,token:i}=Object.assign(e,r),o="https://t{s}.tianditu.gov.cn",s=["0","1","2","3","4","5","6","7"],l=new c.UrlTemplateImageryProvider({url:`${o}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new c.WebMercatorTilingScheme});let u=t.imageryLayers.addImageryProvider(l);u.gamma=1;const f=new c.UrlTemplateImageryProvider({url:`${o}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new c.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(f);const T=new c.UrlTemplateImageryProvider({url:`${o}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new c.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(T)}function E(t,r){B(t,r)}function S(t,r,e,a){(!a||!a.type)&&(a=Object.assign({},e,a));const n=a.type||"Point";let i;switch(n){case"Point":i=D(t,r,e,a);break;case"MultiLineString":case"LineString":i=R(t,r,e,a);break;case"Wms":e=e||a,i=H(t,r,e);break}return i}function D(t,r,e,a){const n=t.scene.primitives.add(new c.BillboardCollection);return n._layerName=r,e.forEach((i,o)=>{const s={scale:1,verticalOrigin:c.VerticalOrigin.BOTTOM,show:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new c.NearFarScalar(1,1,1e5,.2)},l={position:c.Cartesian3.fromDegrees(...P.getLonLat(i),1),image:a.image||a.getImage(i),id:i.id||`point_${o}`},u=n.add(m(m(m({},s),a),l));u._originStyle=p(m(m(m({},s),a),l),{color:c.Color.WHITE}),u.properties=i}),t.scene.requestRender(),n}function R(t,r,e,a){if(e.length<2)return;const n=j(e,a),i=new c.GroundPolylinePrimitive({geometryInstances:n,appearance:new c.PolylineColorAppearance({translucent:!0}),interleave:!0,allowPicking:!0,asynchronous:!1});return i._layerName=r,t.scene.groundPrimitives.add(i),i}function j(t,r){const e=[],a=t.map(o=>c.Cartesian3.fromDegrees(...P.getLonLat(o),0)),n=new c.GroundPolylineGeometry({positions:a,width:r.width||4,granularity:r.granularity||2e3}),i=new c.GeometryInstance({id:"pipeLine",geometry:n,attributes:{color:c.ColorGeometryInstanceAttribute.fromColor(c.Color.fromCssColorString(r.color))}});return e.push(i),e}function H(t,r,e){const a=new c.WebMapServiceImageryProvider({url:e.url,layers:e.layers,parameters:{service:"WMS",version:"1.1.1",request:"GetMap",transparent:!0,format:"image/png"}});a._layerName=r;const n=t.imageryLayers.addImageryProvider(a);return n.alpha=e.alpha||.5,n.brightness=e.brightness||1,n.contrast=e.contrast||1,n.gamma=e.gamma||0,n}function N(t,r){const e=t.scene.primitives.add(new c.BillboardCollection);return e._layerName=r,e}function h(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}function $(t,r){const e=h(t,r);e?t.scene.primitives.remove(e):console.warn("Layer not found:",r)}function q(t,r,e){const a=h(t,r);a?a.show=e:console.warn("Primitive not found:",r)}const g=new Map,d={},y={},W=(t,r)=>{g.has(t)&&console.warn(`Map with target '${t}' already exists. Overwriting...`),g.set(t,r),d[t]&&(d[t].forEach(e=>e(r)),delete d[t]),y[t]&&(y[t].forEach(e=>e(r)),delete y[t])};function w(t){const r=g.get(t);return r?Promise.resolve(r):new Promise(e=>{y[t]=y[t]||[],y[t].push(e)})}const V=t=>{g.has(t)&&(g.delete(t),delete d[t])},M=(t,r)=>{const e=g.get(t);if(e){r(e);return}d[t]||(d[t]=[]),d[t].push(r)};function G(t,r={}){const e=new c.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,alpha:!0}}});let a;return c.defined(r.terrainUrl)?c.CesiumTerrainProvider.fromUrl(r.terrainUrl,{requestVertexNormals:!0,requestWaterMask:!0}).then(n=>{a=n,e.terrainProvider=a}):a=new c.EllipsoidTerrainProvider,e.terrainProvider=a,e._cesiumWidget._creditContainer.style.display="none",e.scene.globe.baseColor=new c.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 U(t,r,e,a){S(t,r,e,p(m({},a),{type:"Point"}))}function A(t,r,e){return new Promise((a,n)=>{t.camera.flyTo({destination:c.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||c.EasingFunction.LINEAR_NONE,maximumHeight:e.maxHeight||1e6,complete:()=>{a(!0)},cancel:()=>{a(!1)}})})}function F(t,r=1){return t.camera.flyHome(r)}function z(t,r,e){return new Promise((a,n)=>{t.camera.flyToBoundingSphere(r,{duration:e.duration||1e3,offset:new c.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 Z(t,r,e){t.camera.setView({destination:c.Cartesian3.fromDegrees(...r),orientation:{heading:e.heading||0,pitch:e.pitch||-Math.PI/2,roll:e.roll||0}})}function K(t,r){t.destroy(),V(r)}function Y(t,r=500){let e=0;return function(...a){const n=Date.now();n-e>=r&&(e=n,t.apply(this,a))}}function J(t,r){const e=new Set,a=new c.ScreenSpaceEventHandler(t.scene.canvas);let n=null;a.setInputAction(o=>{const s=t.scene.pick(o.position);if(n&&(Object.assign(n,n._originStyle),n=null,t.scene.requestRender()),c.defined(s)&&s.primitive instanceof c.Billboard){const l=s.primitive,u={primitive:l,properties:l.properties,event:o,pick:s};n=l,i(u),Object.assign(l,r.style||r.getStyle(l)),t.scene.requestRender()}},c.ScreenSpaceEventType.LEFT_CLICK);const i=o=>e.forEach(s=>s(o));return{onSelect:o=>(e.add(o),()=>e.delete(o)),clear(){e.clear()},destroy(){e.clear()}}}function Q(t,r){const e=new Set,a=s=>e.forEach(l=>l(s)),n=new c.ScreenSpaceEventHandler(t.scene.canvas);let i=null;const o=Y(a,r.delay||500);return n.setInputAction(s=>{const l=t.scene.pick(s.endPosition);if(i&&(Object.assign(i,i._originStyle),i=null,t.scene.requestRender()),c.defined(l)&&l.primitive instanceof c.Billboard){const u=l.primitive,f={primitive:u,properties:u.properties,event:s,pick:l};o(f),i=u,Object.assign(u,r.style||r.getStyle(u)),t.scene.requestRender()}},c.ScreenSpaceEventType.MOUSE_MOVE),{onHover:s=>(e.add(s),()=>e.delete(s)),clear:()=>{e.clear()},destroy:()=>{e.clear()}}}function X(t,r){const e=G(t,r);E(e,r);const a={targetId:t,instance:e,addMarker:(n,i,o)=>U(e,n,i,o),createLayer:(n,i,o)=>S(e,n,i,o),removeLayer:n=>$(e,n),visibleLayer:(n,i)=>q(e,n,i),getLayerByName:n=>h(e,n),createBlankLayer:n=>N(e,n),createSelect:n=>J(e,n),createHover:n=>Q(e,n),flyTo:(n,i)=>A(e,n,i),flyHome:n=>F(e,n),flyToBoundingSphere:(n,i)=>z(e,n,i),setView:(n,i)=>Z(e,n,i),getMapContext:n=>w(n),onMapReady:(n,i)=>M(n,i),destroyMap:n=>K(e,n)};return W(t,a),a}function ee(t,r){M(t,r)}function te(t){return w(t)}exports.getMapContext=te;exports.onMapReady=ee;exports.useMap=X;
|
package/dist/3d/index.mjs
CHANGED
|
@@ -1,73 +1,170 @@
|
|
|
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, I = Object.defineProperties;
|
|
2
|
+
var L = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var k = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var P = (r, t, e) => t in r ? C(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, m = (r, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
k.call(t, e) && P(r, e, t[e]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var e of v(t))
|
|
10
|
+
x.call(t, e) && P(r, e, t[e]);
|
|
11
|
+
return r;
|
|
12
|
+
}, p = (r, t) => I(r, L(t));
|
|
13
|
+
import * as c from "cesium";
|
|
14
|
+
import { getLonLat as b } from "../index.mjs";
|
|
15
|
+
function O(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), o = "https://t{s}.tianditu.gov.cn", s = ["0", "1", "2", "3", "4", "5", "6", "7"], l = new c.UrlTemplateImageryProvider({
|
|
21
|
+
url: `${o}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
22
|
+
subdomains: s,
|
|
23
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
24
|
+
});
|
|
25
|
+
let u = r.imageryLayers.addImageryProvider(l);
|
|
26
|
+
u.gamma = 1;
|
|
27
|
+
const f = new c.UrlTemplateImageryProvider({
|
|
28
|
+
url: `${o}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
29
|
+
subdomains: s,
|
|
30
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
31
|
+
});
|
|
32
|
+
r.imageryLayers.addImageryProvider(f);
|
|
33
|
+
const M = new c.UrlTemplateImageryProvider({
|
|
34
|
+
url: `${o}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
35
|
+
subdomains: s,
|
|
36
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
37
|
+
// maximumLevel: 18
|
|
38
|
+
});
|
|
39
|
+
r.imageryLayers.addImageryProvider(M);
|
|
40
|
+
}
|
|
41
|
+
function B(r, t) {
|
|
42
|
+
O(r, t);
|
|
43
|
+
}
|
|
44
|
+
function w(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 = _(r, t, e, a);
|
|
51
|
+
break;
|
|
52
|
+
case "MultiLineString":
|
|
53
|
+
case "LineString":
|
|
54
|
+
i = E(r, t, e, a);
|
|
55
|
+
break;
|
|
56
|
+
case "Wms":
|
|
57
|
+
e = e || a, i = H(r, t, e);
|
|
58
|
+
break;
|
|
51
59
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
return i;
|
|
61
|
+
}
|
|
62
|
+
function _(r, t, e, a) {
|
|
63
|
+
const n = r.scene.primitives.add(new c.BillboardCollection());
|
|
64
|
+
return n._layerName = t, e.forEach((i, o) => {
|
|
65
|
+
const s = {
|
|
66
|
+
scale: 1,
|
|
67
|
+
// 缩放比例
|
|
68
|
+
verticalOrigin: c.VerticalOrigin.BOTTOM,
|
|
69
|
+
// 以底部为定位中心
|
|
70
|
+
show: !0,
|
|
71
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
72
|
+
// 禁止深度测试距离
|
|
73
|
+
scaleByDistance: new c.NearFarScalar(1, 1, 1e5, 0.2)
|
|
74
|
+
// 根据相机距离缩放
|
|
75
|
+
}, l = {
|
|
76
|
+
position: c.Cartesian3.fromDegrees(...b(i), 1),
|
|
77
|
+
image: a.image || a.getImage(i),
|
|
78
|
+
id: i.id || `point_${o}`
|
|
79
|
+
}, u = n.add(m(m(m({}, s), a), l));
|
|
80
|
+
u._originStyle = p(m(m(m({}, s), a), l), { color: c.Color.WHITE }), u.properties = i;
|
|
81
|
+
}), r.scene.requestRender(), n;
|
|
82
|
+
}
|
|
83
|
+
function E(r, t, e, a) {
|
|
84
|
+
if (e.length < 2) return;
|
|
85
|
+
const n = D(e, a), i = new c.GroundPolylinePrimitive({
|
|
86
|
+
geometryInstances: n,
|
|
87
|
+
appearance: new c.PolylineColorAppearance({
|
|
88
|
+
translucent: !0
|
|
89
|
+
}),
|
|
90
|
+
interleave: !0,
|
|
91
|
+
allowPicking: !0,
|
|
92
|
+
asynchronous: !1
|
|
93
|
+
});
|
|
94
|
+
return i._layerName = t, r.scene.groundPrimitives.add(i), i;
|
|
95
|
+
}
|
|
96
|
+
function D(r, t) {
|
|
97
|
+
const e = [], a = r.map((o) => c.Cartesian3.fromDegrees(...b(o), 0)), n = new c.GroundPolylineGeometry({
|
|
98
|
+
positions: a,
|
|
99
|
+
width: t.width || 4,
|
|
100
|
+
granularity: t.granularity || 2e3
|
|
101
|
+
}), i = new c.GeometryInstance({
|
|
102
|
+
id: "pipeLine",
|
|
103
|
+
geometry: n,
|
|
104
|
+
attributes: {
|
|
105
|
+
color: c.ColorGeometryInstanceAttribute.fromColor(c.Color.fromCssColorString(t.color))
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return e.push(i), e;
|
|
109
|
+
}
|
|
110
|
+
function H(r, t, e) {
|
|
111
|
+
const a = new c.WebMapServiceImageryProvider({
|
|
112
|
+
url: e.url,
|
|
113
|
+
layers: e.layers,
|
|
114
|
+
parameters: {
|
|
115
|
+
service: "WMS",
|
|
116
|
+
version: "1.1.1",
|
|
117
|
+
request: "GetMap",
|
|
118
|
+
transparent: !0,
|
|
119
|
+
format: "image/png"
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
a._layerName = t;
|
|
123
|
+
const n = r.imageryLayers.addImageryProvider(a);
|
|
124
|
+
return n.alpha = e.alpha || 0.5, n.brightness = e.brightness || 1, n.contrast = e.contrast || 1, n.gamma = e.gamma || 0, n;
|
|
125
|
+
}
|
|
126
|
+
function R(r, t) {
|
|
127
|
+
const e = r.scene.primitives.add(new c.BillboardCollection());
|
|
128
|
+
return e._layerName = t, e;
|
|
129
|
+
}
|
|
130
|
+
function h(r, t) {
|
|
131
|
+
const e = r.scene.primitives, a = e.length;
|
|
132
|
+
for (let n = 0; n < a; n++) {
|
|
133
|
+
const i = e.get(n);
|
|
134
|
+
if (i._layerName === t)
|
|
135
|
+
return i;
|
|
60
136
|
}
|
|
137
|
+
return null;
|
|
61
138
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
139
|
+
function $(r, t) {
|
|
140
|
+
const e = h(r, t);
|
|
141
|
+
e ? r.scene.primitives.remove(e) : console.warn("Layer not found:", t);
|
|
142
|
+
}
|
|
143
|
+
function N(r, t, e) {
|
|
144
|
+
const a = h(r, t);
|
|
145
|
+
a ? a.show = e : console.warn("Primitive not found:", t);
|
|
146
|
+
}
|
|
147
|
+
const g = /* @__PURE__ */ new Map(), d = {}, y = {}, j = (r, t) => {
|
|
148
|
+
g.has(r) && console.warn(`Map with target '${r}' already exists. Overwriting...`), g.set(r, t), d[r] && (d[r].forEach((e) => e(t)), delete d[r]), y[r] && (y[r].forEach((e) => e(t)), delete y[r]);
|
|
149
|
+
};
|
|
150
|
+
function S(r) {
|
|
151
|
+
const t = g.get(r);
|
|
152
|
+
return t ? Promise.resolve(t) : new Promise((e) => {
|
|
153
|
+
y[r] = y[r] || [], y[r].push(e);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const W = (r) => {
|
|
157
|
+
g.has(r) && (g.delete(r), delete d[r]);
|
|
158
|
+
}, T = (r, t) => {
|
|
159
|
+
const e = g.get(r);
|
|
160
|
+
if (e) {
|
|
161
|
+
t(e);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
d[r] || (d[r] = []), d[r].push(t);
|
|
165
|
+
};
|
|
166
|
+
function q(r, t = {}) {
|
|
167
|
+
const e = new c.Viewer(r, {
|
|
71
168
|
requestRenderMode: !0,
|
|
72
169
|
//减少应用程序的 CPU/GPU 使用率
|
|
73
170
|
maximumRenderTimeChange: 1 / 0,
|
|
@@ -83,7 +180,7 @@ function y(r, a) {
|
|
|
83
180
|
//控制右上角home按钮显示
|
|
84
181
|
baseLayerPicker: !1,
|
|
85
182
|
//地图切换控件(底图以及地形图)是否显示,默认显示true
|
|
86
|
-
imageryProvider: new
|
|
183
|
+
// imageryProvider: new Cesium.GridImageryProvider({}),
|
|
87
184
|
sceneModePicker: !1,
|
|
88
185
|
navigationHelpButton: !1,
|
|
89
186
|
infoBox: !1,
|
|
@@ -92,29 +189,175 @@ function y(r, a) {
|
|
|
92
189
|
//全屏按钮,默认显示true
|
|
93
190
|
shouldAnimate: !0,
|
|
94
191
|
// Enable animations
|
|
95
|
-
terrainProvider: e,
|
|
96
192
|
contextOptions: {
|
|
97
193
|
webgl: {
|
|
98
|
-
preserveDrawingBuffer: !0
|
|
194
|
+
preserveDrawingBuffer: !0,
|
|
99
195
|
//允许截图
|
|
196
|
+
alpha: !0
|
|
197
|
+
//允许透明
|
|
100
198
|
}
|
|
101
199
|
}
|
|
102
200
|
});
|
|
103
|
-
|
|
201
|
+
let a;
|
|
202
|
+
return c.defined(t.terrainUrl) ? c.CesiumTerrainProvider.fromUrl(t.terrainUrl, {
|
|
203
|
+
requestVertexNormals: !0,
|
|
204
|
+
requestWaterMask: !0
|
|
205
|
+
}).then((n) => {
|
|
206
|
+
a = n, e.terrainProvider = a;
|
|
207
|
+
}) : a = new c.EllipsoidTerrainProvider(), e.terrainProvider = a, e._cesiumWidget._creditContainer.style.display = "none", e.scene.globe.baseColor = new c.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;
|
|
208
|
+
}
|
|
209
|
+
function V(r, t, e, a) {
|
|
210
|
+
w(r, t, e, p(m({}, a), { type: "Point" }));
|
|
211
|
+
}
|
|
212
|
+
function G(r, t, e) {
|
|
213
|
+
return new Promise((a, n) => {
|
|
214
|
+
r.camera.flyTo({
|
|
215
|
+
destination: c.Cartesian3.fromDegrees(...t),
|
|
216
|
+
duration: e.duration || 1.2,
|
|
217
|
+
// 飞行动画时间(秒)
|
|
218
|
+
orientation: {
|
|
219
|
+
heading: e.heading || 0,
|
|
220
|
+
pitch: e.pitch || -Math.PI / 2,
|
|
221
|
+
roll: e.roll || 0
|
|
222
|
+
},
|
|
223
|
+
easingFunction: e.easing || c.EasingFunction.LINEAR_NONE,
|
|
224
|
+
// 飞行动画缓动函数
|
|
225
|
+
maximumHeight: e.maxHeight || 1e6,
|
|
226
|
+
// 相机最大飞行高度
|
|
227
|
+
complete: () => {
|
|
228
|
+
a(!0);
|
|
229
|
+
},
|
|
230
|
+
cancel: () => {
|
|
231
|
+
a(!1);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
104
235
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
236
|
+
function U(r, t = 1) {
|
|
237
|
+
return r.camera.flyHome(t);
|
|
107
238
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
239
|
+
function A(r, t, e) {
|
|
240
|
+
return new Promise((a, n) => {
|
|
241
|
+
r.camera.flyToBoundingSphere(t, {
|
|
242
|
+
duration: e.duration || 1e3,
|
|
243
|
+
// 飞行动画时间(秒)
|
|
244
|
+
offset: new c.HeadingPitchRange(e.heading || 0, e.pitch || -Math.PI / 4, e.roll || 0),
|
|
245
|
+
easingFunction: e.easing,
|
|
246
|
+
// 飞行动画缓动函数
|
|
247
|
+
maximumHeight: e.maxHeight || 1e6,
|
|
248
|
+
// 相机最大飞行高度
|
|
249
|
+
complete: () => {
|
|
250
|
+
a(!0);
|
|
251
|
+
},
|
|
252
|
+
cancel: () => {
|
|
253
|
+
a(!1);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function F(r, t, e) {
|
|
259
|
+
r.camera.setView({
|
|
260
|
+
destination: c.Cartesian3.fromDegrees(...t),
|
|
261
|
+
orientation: {
|
|
262
|
+
heading: e.heading || 0,
|
|
263
|
+
pitch: e.pitch || -Math.PI / 2,
|
|
264
|
+
roll: e.roll || 0
|
|
265
|
+
}
|
|
266
|
+
});
|
|
110
267
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
268
|
+
function Z(r, t) {
|
|
269
|
+
r.destroy(), W(t);
|
|
270
|
+
}
|
|
271
|
+
function z(r, t = 500) {
|
|
272
|
+
let e = 0;
|
|
273
|
+
return function(...a) {
|
|
274
|
+
const n = Date.now();
|
|
275
|
+
n - e >= t && (e = n, r.apply(this, a));
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function K(r, t) {
|
|
279
|
+
const e = /* @__PURE__ */ new Set(), a = new c.ScreenSpaceEventHandler(r.scene.canvas);
|
|
280
|
+
let n = null;
|
|
281
|
+
a.setInputAction((o) => {
|
|
282
|
+
const s = r.scene.pick(o.position);
|
|
283
|
+
if (n && (Object.assign(n, n._originStyle), n = null, r.scene.requestRender()), c.defined(s) && s.primitive instanceof c.Billboard) {
|
|
284
|
+
const l = s.primitive, u = {
|
|
285
|
+
primitive: l,
|
|
286
|
+
properties: l.properties,
|
|
287
|
+
event: o,
|
|
288
|
+
pick: s
|
|
289
|
+
};
|
|
290
|
+
n = l, i(u), Object.assign(l, t.style || t.getStyle(l)), r.scene.requestRender();
|
|
291
|
+
}
|
|
292
|
+
}, c.ScreenSpaceEventType.LEFT_CLICK);
|
|
293
|
+
const i = (o) => e.forEach((s) => s(o));
|
|
294
|
+
return {
|
|
295
|
+
onSelect: (o) => (e.add(o), () => e.delete(o)),
|
|
296
|
+
clear() {
|
|
297
|
+
e.clear();
|
|
298
|
+
},
|
|
299
|
+
destroy() {
|
|
300
|
+
e.clear();
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function Y(r, t) {
|
|
305
|
+
const e = /* @__PURE__ */ new Set(), a = (s) => e.forEach((l) => l(s)), n = new c.ScreenSpaceEventHandler(r.scene.canvas);
|
|
306
|
+
let i = null;
|
|
307
|
+
const o = z(a, t.delay || 500);
|
|
308
|
+
return n.setInputAction((s) => {
|
|
309
|
+
const l = r.scene.pick(s.endPosition);
|
|
310
|
+
if (i && (Object.assign(i, i._originStyle), i = null, r.scene.requestRender()), c.defined(l) && l.primitive instanceof c.Billboard) {
|
|
311
|
+
const u = l.primitive, f = {
|
|
312
|
+
primitive: u,
|
|
313
|
+
properties: u.properties,
|
|
314
|
+
event: s,
|
|
315
|
+
pick: l
|
|
316
|
+
};
|
|
317
|
+
o(f), i = u, Object.assign(u, t.style || t.getStyle(u)), r.scene.requestRender();
|
|
318
|
+
}
|
|
319
|
+
}, c.ScreenSpaceEventType.MOUSE_MOVE), {
|
|
320
|
+
onHover: (s) => (e.add(s), () => e.delete(s)),
|
|
321
|
+
clear: () => {
|
|
322
|
+
e.clear();
|
|
323
|
+
},
|
|
324
|
+
destroy: () => {
|
|
325
|
+
e.clear();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function X(r, t) {
|
|
330
|
+
const e = q(r, t);
|
|
331
|
+
B(e, t);
|
|
332
|
+
const a = {
|
|
333
|
+
targetId: r,
|
|
114
334
|
instance: e,
|
|
115
|
-
addMarker: (
|
|
335
|
+
addMarker: (n, i, o) => V(e, n, i, o),
|
|
336
|
+
createLayer: (n, i, o) => w(e, n, i, o),
|
|
337
|
+
removeLayer: (n) => $(e, n),
|
|
338
|
+
visibleLayer: (n, i) => N(e, n, i),
|
|
339
|
+
getLayerByName: (n) => h(e, n),
|
|
340
|
+
createBlankLayer: (n) => R(e, n),
|
|
341
|
+
createSelect: (n) => K(e, n),
|
|
342
|
+
createHover: (n) => Y(e, n),
|
|
343
|
+
flyTo: (n, i) => G(e, n, i),
|
|
344
|
+
flyHome: (n) => U(e, n),
|
|
345
|
+
flyToBoundingSphere: (n, i) => A(e, n, i),
|
|
346
|
+
setView: (n, i) => F(e, n, i),
|
|
347
|
+
getMapContext: (n) => S(n),
|
|
348
|
+
onMapReady: (n, i) => T(n, i),
|
|
349
|
+
destroyMap: (n) => Z(e, n)
|
|
116
350
|
};
|
|
351
|
+
return j(r, a), a;
|
|
352
|
+
}
|
|
353
|
+
function ee(r, t) {
|
|
354
|
+
T(r, t);
|
|
355
|
+
}
|
|
356
|
+
function re(r) {
|
|
357
|
+
return S(r);
|
|
117
358
|
}
|
|
118
359
|
export {
|
|
119
|
-
|
|
360
|
+
re as getMapContext,
|
|
361
|
+
ee as onMapReady,
|
|
362
|
+
X as useMap
|
|
120
363
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { billboardOptions } from './types';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
export interface SelectResult {
|
|
4
|
+
primitive: Cesium.Primitive;
|
|
5
|
+
properties: any;
|
|
6
|
+
event: Cesium.Cartesian2;
|
|
7
|
+
pick: any;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSelectResult {
|
|
10
|
+
onSelect: (result: (SelectResult: any) => void) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface SelectOptions {
|
|
15
|
+
style?: billboardOptions;
|
|
16
|
+
getStyle?: (primitive: Cesium.Primitive) => billboardOptions;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 创建选择功能
|
|
20
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
21
|
+
* @param {SelectOptions} options 配置项
|
|
22
|
+
* @returns {UseSelectResult}
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSelect(viewer: Cesium.Viewer, options: SelectOptions): UseSelectResult;
|
|
25
|
+
export interface HoverEvent {
|
|
26
|
+
primitive: Cesium.Primitive;
|
|
27
|
+
properties: any;
|
|
28
|
+
event: Cesium.Cartesian2;
|
|
29
|
+
pick: any;
|
|
30
|
+
}
|
|
31
|
+
export interface HoverOptions {
|
|
32
|
+
delay?: number;
|
|
33
|
+
style?: billboardOptions;
|
|
34
|
+
getStyle?: (primitive: Cesium.Primitive) => billboardOptions;
|
|
35
|
+
}
|
|
36
|
+
export interface UseHoverResult {
|
|
37
|
+
onHover: (result: (HoverEvent: any) => void) => void;
|
|
38
|
+
clear: () => void;
|
|
39
|
+
destroy: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 创建hover事件
|
|
43
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
44
|
+
* @param {HoverOptions} options 配置项
|
|
45
|
+
* @returns {UseHoverResult}
|
|
46
|
+
*/
|
|
47
|
+
export declare function createHover(viewer: Cesium.Viewer, options: HoverOptions): UseHoverResult;
|