diff --git a/lerna.json b/lerna.json index b808377bd1..98835cc551 100644 --- a/lerna.json +++ b/lerna.json @@ -14,7 +14,7 @@ "message": "chore: publish" } }, - "version": "2.5.33", + "version": "2.5.34", "npmClient": "yarn", "useWorkspaces": true, "publishConfig": { diff --git a/packages/component/package.json b/packages/component/package.json index 5c9dd6889e..397035d6e0 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-component", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -25,8 +25,8 @@ "author": "lzxue", "license": "ISC", "dependencies": { - "@antv/l7-core": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-core": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "eventemitter3": "^4.0.0", "inversify": "^5.0.1", diff --git a/packages/core/package.json b/packages/core/package.json index 37a8960168..b203e56561 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-core", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -24,7 +24,7 @@ "license": "ISC", "dependencies": { "@antv/async-hook": "^2.1.0", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "@mapbox/tiny-sdf": "^1.1.1", "ajv": "^6.10.2", diff --git a/packages/core/src/services/map/IMapService.ts b/packages/core/src/services/map/IMapService.ts index 2ee1568fb3..4e5dc4a38c 100644 --- a/packages/core/src/services/map/IMapService.ts +++ b/packages/core/src/services/map/IMapService.ts @@ -106,7 +106,85 @@ export interface IMapService { } | undefined, ): void; - clearColor?(): void; +} + +export interface IEarthService { + version?: string; + map: RawMap; + bgColor: string; + setBgColor(color: string): void; + init(): void; + initViewPort?(): void; + destroy(): void; + onCameraChanged(callback: (viewport: IViewport) => void): void; + // init map + addMarkerContainer(): void; + getMarkerContainer(): HTMLElement; + // MapEvent // 定义事件类型 + + on(type: string, handler: (...args: any[]) => void): void; + off(type: string, handler: (...args: any[]) => void): void; + once(type: string, handler: (...args: any[]) => void): void; + // get dom + getContainer(): HTMLElement | null; + getSize(): [number, number]; + // get map status method + getMinZoom(): number; + getMaxZoom(): number; + // get map params + getType(): string; + getZoom(): number; + getCenter(option?: ICameraOptions): ILngLat; + getPitch(): number; + getRotation(): number; + getBounds(): Bounds; + getMapContainer(): HTMLElement | null; + getMapCanvasContainer(): HTMLElement; + + // control with raw map + setRotation(rotation: number): void; + zoomIn(option?: any, eventData?: any): void; + zoomOut(option?: any, eventData?: any): void; + panTo(p: Point): void; + panBy(x: number, y: number): void; + fitBounds(bound: Bounds, fitBoundsOptions?: unknown): void; + setZoomAndCenter(zoom: number, center: Point): void; + setCenter(center: [number, number], option?: ICameraOptions): void; + setPitch(pitch: number): void; + setZoom(zoom: number): void; + setMapStyle(style: any): void; + setMapStatus(option: Partial): void; + + // coordinates methods + pixelToLngLat(pixel: Point): ILngLat; + lngLatToPixel(lnglat: Point): IPoint; + containerToLngLat(pixel: Point): ILngLat; + lngLatToContainer(lnglat: Point): IPoint; + lngLatToMercator(lnglat: [number, number], altitude: number): IMercator; + getModelMatrix( + lnglat: [number, number], + altitude: number, + rotate: [number, number, number], + scale: [number, number, number], + origin: IMercator, + ): number[]; + lngLatToCoord?(lnglat: [number, number]): [number, number]; + lngLatToCoords?( + lnglatArray: number[][][] | number[][], + ): number[][][] | number[][] | number[][][] | number[][]; + // lngLatToCoords?(lnglatArray: any): any; + getCustomCoordCenter?(): [number, number]; + exportMap(type: 'jpg' | 'png'): string; + + // 地球模式下的地图方法/属性 + rotateY?( + option: + | { + force?: boolean; + reg?: number; + } + | undefined, + ): void; } export const MapServiceEvent = ['mapload']; diff --git a/packages/l7/package.json b/packages/l7/package.json index 0d92d425aa..bcad369258 100644 --- a/packages/l7/package.json +++ b/packages/l7/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7", - "version": "2.5.33", + "version": "2.5.34", "description": "A Large-scale WebGL-powered Geospatial Data Visualization", "main": "lib/index.js", "module": "es/index.js", @@ -25,12 +25,12 @@ "author": "antv", "license": "MIT", "dependencies": { - "@antv/l7-component": "^2.5.33", - "@antv/l7-core": "^2.5.33", - "@antv/l7-layers": "^2.5.33", - "@antv/l7-maps": "^2.5.33", - "@antv/l7-scene": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-component": "^2.5.34", + "@antv/l7-core": "^2.5.34", + "@antv/l7-layers": "^2.5.34", + "@antv/l7-maps": "^2.5.34", + "@antv/l7-scene": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7" }, "gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31", diff --git a/packages/l7/src/version.ts b/packages/l7/src/version.ts index 36a721c77f..f6179f4f48 100644 --- a/packages/l7/src/version.ts +++ b/packages/l7/src/version.ts @@ -1,2 +1,2 @@ -const version = '2.5.33'; +const version = '2.5.34'; export { version }; diff --git a/packages/layers/package.json b/packages/layers/package.json index 0a52605bc9..e83b7a730b 100644 --- a/packages/layers/package.json +++ b/packages/layers/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-layers", - "version": "2.5.33", + "version": "2.5.34", "description": "L7's collection of built-in layers", "main": "lib/index.js", "module": "es/index.js", @@ -24,9 +24,9 @@ "license": "ISC", "dependencies": { "@antv/async-hook": "^2.1.0", - "@antv/l7-core": "^2.5.33", - "@antv/l7-source": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-core": "^2.5.34", + "@antv/l7-source": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "@mapbox/martini": "^0.2.0", "@turf/meta": "^6.0.2", diff --git a/packages/map/package.json b/packages/map/package.json index 95a113dab7..2c903d10b8 100644 --- a/packages/map/package.json +++ b/packages/map/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-map", - "version": "2.5.33", + "version": "2.5.34", "description": "l7 map", "keywords": [], "author": "thinkinggis ", @@ -37,7 +37,7 @@ }, "homepage": "https://github.com/antvis/L7#readme", "dependencies": { - "@antv/l7-utils": "^2.5.33", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "@mapbox/point-geometry": "^0.1.0", "@mapbox/unitbezier": "^0.0.0", diff --git a/packages/maps/package.json b/packages/maps/package.json index b741ae8c68..af23748258 100644 --- a/packages/maps/package.json +++ b/packages/maps/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-maps", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -27,9 +27,9 @@ "license": "ISC", "dependencies": { "@amap/amap-jsapi-loader": "^0.0.3", - "@antv/l7-core": "^2.5.33", - "@antv/l7-map": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-core": "^2.5.34", + "@antv/l7-map": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "@types/amap-js-api": "^1.4.6", "@types/mapbox-gl": "^1.11.2", diff --git a/packages/maps/src/earth/Viewport.ts b/packages/maps/src/earth/Viewport.ts index 428c357c9c..d943e77a4e 100644 --- a/packages/maps/src/earth/Viewport.ts +++ b/packages/maps/src/earth/Viewport.ts @@ -2,6 +2,11 @@ import { IMapCamera, IViewport } from '@antv/l7-core'; import { mat4, vec3 } from 'gl-matrix'; import WebMercatorViewport from 'viewport-mercator-project'; +export interface IEarthCamera { + viewportHeight: number; + viewportWidth: number; +} + export default class Viewport implements IViewport { // TODO: 初始化相机的姿态 看向地球 private xzReg: number = -Math.PI * 0.6; @@ -21,7 +26,7 @@ export default class Viewport implements IViewport { private ViewProjectionMatrixUncentered: mat4 = mat4.create(); private viewUncenteredMatrix: mat4 = mat4.create(); - public syncWithMapCamera(mapCamera: Partial) { + public syncWithMapCamera(mapCamera: Partial) { const { viewportHeight = 1, viewportWidth = 1 } = mapCamera; const aspect = viewportWidth / viewportHeight; const near = 0.1; diff --git a/packages/maps/src/earth/map.ts b/packages/maps/src/earth/map.ts index 06fdb3b195..5443116b02 100644 --- a/packages/maps/src/earth/map.ts +++ b/packages/maps/src/earth/map.ts @@ -5,13 +5,12 @@ import { Bounds, CoordinateSystem, ICoordinateSystemService, + IEarthService, IGlobalConfigService, ILngLat, IMapConfig, - IMapService, IMercator, IPoint, - IRendererService, IStatusOptions, IViewport, MapServiceEvent, @@ -39,7 +38,7 @@ const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; * AMapService */ @injectable() -export default class L7MapService implements IMapService { +export default class L7EarthService implements IEarthService { public version: string = Version.GLOBEL; public map: Map; @@ -55,9 +54,6 @@ export default class L7MapService implements IMapService { @inject(TYPES.ICoordinateSystemService) private readonly coordinateSystemService: ICoordinateSystemService; - @inject(TYPES.IRendererService) - private readonly renderService: IRendererService; - @inject(TYPES.IEventEmitter) private eventEmitter: any; private viewport: Viewport; @@ -332,23 +328,14 @@ export default class L7MapService implements IMapService { this.viewport.rotateY(reg); this.viewport.syncWithMapCamera({ - bearing: this.map.getBearing(), viewportHeight: this.map.transform.height, - pitch: this.map.getPitch(), viewportWidth: this.map.transform.width, - zoom: this.map.getZoom(), - // mapbox 中固定相机高度为 viewport 高度的 1.5 倍 - cameraHeight: 0, }); this.cameraChangedCallback(this.viewport); } } - public clearColor() { - this.renderService.clear({ color: [0.0, 0.0, 0.0, 1.0] }); - } - private handleCameraChanged = (e: any) => { const DELAY_TIME = 2000; this.handleCameraChanging = true; @@ -389,13 +376,8 @@ export default class L7MapService implements IMapService { // resync this.viewport.syncWithMapCamera({ - bearing: this.map.getBearing(), viewportHeight: this.map.transform.height, - pitch: this.map.getPitch(), viewportWidth: this.map.transform.width, - zoom: this.map.getZoom(), - // mapbox 中固定相机高度为 viewport 高度的 1.5 倍 - cameraHeight: 0, }); // set coordinate system if ( diff --git a/packages/renderer/package.json b/packages/renderer/package.json index ca5580de8e..b7b7e4218b 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-renderer", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -26,7 +26,7 @@ "gl": "^4.4.0" }, "dependencies": { - "@antv/l7-core": "^2.5.33", + "@antv/l7-core": "^2.5.34", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "l7regl": "^0.0.14", diff --git a/packages/scene/package.json b/packages/scene/package.json index a44b4897d9..a0277c877e 100644 --- a/packages/scene/package.json +++ b/packages/scene/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-scene", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -23,12 +23,12 @@ "author": "xiaoiver", "license": "ISC", "dependencies": { - "@antv/l7-component": "^2.5.33", - "@antv/l7-core": "^2.5.33", - "@antv/l7-layers": "^2.5.33", - "@antv/l7-maps": "^2.5.33", - "@antv/l7-renderer": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-component": "^2.5.34", + "@antv/l7-core": "^2.5.34", + "@antv/l7-layers": "^2.5.34", + "@antv/l7-maps": "^2.5.34", + "@antv/l7-renderer": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "mapbox-gl": "^1.2.1", diff --git a/packages/source/package.json b/packages/source/package.json index 98b8d5be15..640d41c8d0 100644 --- a/packages/source/package.json +++ b/packages/source/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-source", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -26,8 +26,8 @@ "license": "ISC", "dependencies": { "@antv/async-hook": "^2.1.0", - "@antv/l7-core": "^2.5.33", - "@antv/l7-utils": "^2.5.33", + "@antv/l7-core": "^2.5.34", + "@antv/l7-utils": "^2.5.34", "@babel/runtime": "^7.7.7", "@mapbox/geojson-rewind": "^0.4.0", "@turf/helpers": "^6.1.4", diff --git a/packages/source/src/parser/image.ts b/packages/source/src/parser/image.ts index 57793e801d..af81482e64 100644 --- a/packages/source/src/parser/image.ts +++ b/packages/source/src/parser/image.ts @@ -7,7 +7,8 @@ export default function image( data: string | string[], cfg: IImageCfg, ): IParserData { - const { extent } = cfg; + // TODO: 为 extent 赋默认值 + const { extent = [121.168, 30.2828, 121.384, 30.4219] } = cfg; const images = new Promise((resolve) => { loadData(data, (res: any) => { resolve(res); diff --git a/packages/three/package.json b/packages/three/package.json index 88fd3d92c1..e7a456e437 100644 --- a/packages/three/package.json +++ b/packages/three/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-three", - "version": "2.5.33", + "version": "2.5.34", "description": "three for L7 ", "keywords": [ "3D", @@ -44,9 +44,9 @@ }, "homepage": "https://github.com/antvis/L7#readme", "dependencies": { - "@antv/l7-core": "^2.5.33", - "@antv/l7-layers": "^2.5.33", - "@antv/l7-scene": "^2.5.33", + "@antv/l7-core": "^2.5.34", + "@antv/l7-layers": "^2.5.34", + "@antv/l7-scene": "^2.5.34", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "reflect-metadata": "^0.1.13", diff --git a/packages/utils/package.json b/packages/utils/package.json index 415c554312..29567121bb 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-utils", - "version": "2.5.33", + "version": "2.5.34", "description": "", "main": "lib/index.js", "module": "es/index.js", diff --git a/stories/customMap/components/earth.tsx b/stories/customMap/components/earth.tsx index b069189086..c45140b004 100644 --- a/stories/customMap/components/earth.tsx +++ b/stories/customMap/components/earth.tsx @@ -385,43 +385,17 @@ export default class ScaleComponent extends React.Component { // .animate(true) .active(true); - // scene.addLayer(pointlayer); - - // let pointlayer = new PointLayer() - // .source( - // [ - // { - // lng: 120, - // lat: 30, - // }, - // ], - // { - // parser: { - // type: 'json', - // x: 'lng', - // y: 'lat', - // }, - // }, - // ) - // .shape('circle') - // .color('rgba(255, 0, 0, 1.0)') - // .size(200); - const earthlayer = new EarthLayer() .source( 'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*3-3NSpqRqUoAAAAAAAAAAAAAARQnAQ', { parser: { type: 'image', - extent: [121.168, 30.2828, 121.384, 30.4219], }, }, ) - .color('#2E8AE6') - .shape('fill') + .shape('base') .style({ - opacity: 1.0, - radius: 40, globelOtions: { ambientRatio: 0.6, // 环境光 diffuseRatio: 0.4, // 漫反射 diff --git a/stories/customMap/components/earth2.tsx b/stories/customMap/components/earth2.tsx index ecea895796..ab60d1b937 100644 --- a/stories/customMap/components/earth2.tsx +++ b/stories/customMap/components/earth2.tsx @@ -14,11 +14,7 @@ export default class ScaleComponent extends React.Component { public async componentDidMount() { const scene = new Scene({ id: 'map', - map: new Earth({ - center: [120, 30], - pitch: 0, - zoom: 3, - }), + map: new Earth({}), }); scene.setBgColor('#333'); @@ -70,16 +66,11 @@ export default class ScaleComponent extends React.Component { { parser: { type: 'image', - extent: [121.168, 30.2828, 121.384, 30.4219], }, }, ) - // .color('#2E8AE6') - .color('#f00') .shape('fill') .style({ - opacity: 1.0, - radius: 40, globelOtions: { ambientRatio: 0.6, // 环境光 diffuseRatio: 0.4, // 漫反射