From 9fa15e4d2a01fc25c7ea0f62e4779b3ab7c06c2e Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Thu, 26 Dec 2019 11:42:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=AB=98=E5=BE=B7=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=BA=95=E5=9B=BE=E6=A8=A1=E5=BC=8F,=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=B3=A8=E5=86=8C=E9=A1=BA=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interaction/InteractionService.ts | 1 - .../core/src/services/scene/SceneService.ts | 4 +- packages/layers/src/core/triangulation.ts | 2 +- packages/maps/src/amap/index.ts | 2 +- stories/Layers/components/Point.tsx | 97 +++++++++---------- 5 files changed, 52 insertions(+), 54 deletions(-) diff --git a/packages/core/src/services/interaction/InteractionService.ts b/packages/core/src/services/interaction/InteractionService.ts index 82be0ee533..f96ac5a262 100644 --- a/packages/core/src/services/interaction/InteractionService.ts +++ b/packages/core/src/services/interaction/InteractionService.ts @@ -68,7 +68,6 @@ export default class InteractionService extends EventEmitter this.logger.debug('add event listeners on canvas'); } } - private removeEventListenerOnMap() { const $containter = this.mapService.getMapContainer(); if ($containter) { diff --git a/packages/core/src/services/scene/SceneService.ts b/packages/core/src/services/scene/SceneService.ts index acdbb76b78..8013c5dd02 100644 --- a/packages/core/src/services/scene/SceneService.ts +++ b/packages/core/src/services/scene/SceneService.ts @@ -137,6 +137,8 @@ export default class Scene extends EventEmitter implements ISceneService { this.map.addMarkerContainer(); // 初始化未加载的marker; this.markerService.addMarkers(); + // 地图初始化之后 才能初始化 container 上的交互 + this.interactionService.init(); this.logger.debug('map loaded'); }); @@ -160,8 +162,6 @@ export default class Scene extends EventEmitter implements ISceneService { this.logger.error('容器 id 不存在'); } - // 初始化 container 上的交互 - this.interactionService.init(); this.logger.debug(`scene ${this.id} renderer loaded`); }); // TODO:init worker, fontAtlas... diff --git a/packages/layers/src/core/triangulation.ts b/packages/layers/src/core/triangulation.ts index 3fa658088c..a059a2c75d 100644 --- a/packages/layers/src/core/triangulation.ts +++ b/packages/layers/src/core/triangulation.ts @@ -47,7 +47,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) { indices: index, normals, // normals: Array.from(computeVertexNormals(positions, index, 3, false)), - size: 3, + size: 5, }; } diff --git a/packages/maps/src/amap/index.ts b/packages/maps/src/amap/index.ts index fd26e3731e..60f55ed26e 100644 --- a/packages/maps/src/amap/index.ts +++ b/packages/maps/src/amap/index.ts @@ -114,7 +114,7 @@ export default class AMapService } public getZoom(): number { // 统一返回 Mapbox 缩放等级 - return this.map.getZoom(); + return this.map.getZoom() - 1; } public setZoom(zoom: number): void { diff --git a/stories/Layers/components/Point.tsx b/stories/Layers/components/Point.tsx index 23642bcb1b..4b092dba1a 100644 --- a/stories/Layers/components/Point.tsx +++ b/stories/Layers/components/Point.tsx @@ -24,59 +24,58 @@ export default class Point3D extends React.Component { pitch: 0, style: 'dark', zoom: 3, - token: 'test', }), }); - scene.on('loaded', () => { - const pointLayer = new PointLayer({}) - .source(pointsData, { - cluster: true, - }) - .shape('circle') - .scale('point_count', { - type: 'quantile', - }) - .size('point_count', [5, 10, 15, 20, 25]) - .color('yellow') - .style({ - opacity: 0.5, - strokeWidth: 1, - }); - scene.addLayer(pointLayer); - pointLayer.on('mousemove', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); + // scene.on('loaded', () => { + const pointLayer = new PointLayer({}) + .source(pointsData, { + cluster: true, + }) + .shape('circle') + .scale('point_count', { + type: 'quantile', + }) + .size('point_count', [5, 10, 15, 20, 25]) + .color('yellow') + .style({ + opacity: 0.5, + strokeWidth: 1, }); - pointLayer.on('mousedown', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); - }); - pointLayer.on('mouseup', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); - }); - pointLayer.on('click', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); - }); - - pointLayer.on('contextmenu', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); - }); - pointLayer.on('unpick', (e) => { - const id = e.featureId; - console.log(e.type); - pointLayer.setActive(id); - }); - - this.scene = scene; + scene.addLayer(pointLayer); + pointLayer.on('mousemove', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); }); + pointLayer.on('mousedown', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); + }); + pointLayer.on('mouseup', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); + }); + pointLayer.on('click', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); + }); + + pointLayer.on('contextmenu', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); + }); + pointLayer.on('unpick', (e) => { + const id = e.featureId; + console.log(e.type); + pointLayer.setActive(id); + }); + + this.scene = scene; + // }); } public render() {