fix: 高德地图底图模式,事件交互注册顺序的问题导致不生效

This commit is contained in:
thinkinggis 2019-12-26 11:42:09 +08:00
parent 853f66671a
commit 4d98324f24
5 changed files with 52 additions and 54 deletions

View File

@ -68,7 +68,6 @@ export default class InteractionService extends EventEmitter
this.logger.debug('add event listeners on canvas'); this.logger.debug('add event listeners on canvas');
} }
} }
private removeEventListenerOnMap() { private removeEventListenerOnMap() {
const $containter = this.mapService.getMapContainer(); const $containter = this.mapService.getMapContainer();
if ($containter) { if ($containter) {

View File

@ -137,6 +137,8 @@ export default class Scene extends EventEmitter implements ISceneService {
this.map.addMarkerContainer(); this.map.addMarkerContainer();
// 初始化未加载的marker; // 初始化未加载的marker;
this.markerService.addMarkers(); this.markerService.addMarkers();
// 地图初始化之后 才能初始化 container 上的交互
this.interactionService.init();
this.logger.debug('map loaded'); this.logger.debug('map loaded');
}); });
@ -160,8 +162,6 @@ export default class Scene extends EventEmitter implements ISceneService {
this.logger.error('容器 id 不存在'); this.logger.error('容器 id 不存在');
} }
// 初始化 container 上的交互
this.interactionService.init();
this.logger.debug(`scene ${this.id} renderer loaded`); this.logger.debug(`scene ${this.id} renderer loaded`);
}); });
// TODOinit worker, fontAtlas... // TODOinit worker, fontAtlas...

View File

@ -47,7 +47,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) {
indices: index, indices: index,
normals, normals,
// normals: Array.from(computeVertexNormals(positions, index, 3, false)), // normals: Array.from(computeVertexNormals(positions, index, 3, false)),
size: 3, size: 5,
}; };
} }

View File

@ -114,7 +114,7 @@ export default class AMapService
} }
public getZoom(): number { public getZoom(): number {
// 统一返回 Mapbox 缩放等级 // 统一返回 Mapbox 缩放等级
return this.map.getZoom(); return this.map.getZoom() - 1;
} }
public setZoom(zoom: number): void { public setZoom(zoom: number): void {

View File

@ -24,10 +24,9 @@ export default class Point3D extends React.Component {
pitch: 0, pitch: 0,
style: 'dark', style: 'dark',
zoom: 3, zoom: 3,
token: 'test',
}), }),
}); });
scene.on('loaded', () => { // scene.on('loaded', () => {
const pointLayer = new PointLayer({}) const pointLayer = new PointLayer({})
.source(pointsData, { .source(pointsData, {
cluster: true, cluster: true,
@ -76,7 +75,7 @@ export default class Point3D extends React.Component {
}); });
this.scene = scene; this.scene = scene;
}); // });
} }
public render() { public render() {