This commit is contained in:
2912401452 2022-03-03 11:53:09 +08:00
commit ed565d8026
3 changed files with 16 additions and 4 deletions

View File

@ -193,7 +193,7 @@ export interface IEarthService<RawMap = {}> {
): void; ): void;
} }
export const MapServiceEvent = ['mapload', 'mapchange']; export const MapServiceEvent = ['mapload', 'mapchange', 'mapAfterFrameChange'];
/** /**
* *

View File

@ -299,6 +299,14 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
TYPES.IPickingService, TYPES.IPickingService,
); );
this.mapService = this.container.get<IMapService>(TYPES.IMapService); this.mapService = this.container.get<IMapService>(TYPES.IMapService);
const { enableMultiPassRenderer, passes } = this.getLayerConfig();
if (enableMultiPassRenderer && passes?.length && passes.length > 0) {
// Tip: 兼容 multiPassRender 在 amap1 时存在的图层不同步问题 zoom
this.mapService.on('mapAfterFrameChange', () => {
this.renderLayers();
});
}
this.cameraService = this.container.get<ICameraService>( this.cameraService = this.container.get<ICameraService>(
TYPES.ICameraService, TYPES.ICameraService,
); );

View File

@ -371,11 +371,11 @@ export default class AMapService
// @ts-ignore // @ts-ignore
const map = new AMap.Map(this.$mapContainer, mapConstructorOptions); const map = new AMap.Map(this.$mapContainer, mapConstructorOptions);
// 监听地图相机事件 // 监听地图相机事件
// map.on('camerachange', this.handleCameraChanged); map.on('camerachange', this.handleCameraChanged);
// Tip: 为了兼容开启 MultiPassRender 的情况 // Tip: 为了兼容开启 MultiPassRender 的情况
// 修复 MultiPassRender 在高德地图 1.x 的情况下,缩放地图改变 zoom 时存在可视化层和底图不同步的现象 // 修复 MultiPassRender 在高德地图 1.x 的情况下,缩放地图改变 zoom 时存在可视化层和底图不同步的现象
map.on('camerachange', (e) => { map.on('camerachange', () => {
setTimeout(() => this.handleCameraChanged(e)); setTimeout(() => this.handleAfterMapChange());
}); });
// @ts-ignore // @ts-ignore
@ -476,6 +476,10 @@ export default class AMapService
this.cameraChangedCallback = callback; this.cameraChangedCallback = callback;
} }
private handleAfterMapChange() {
this.emit('mapAfterFrameChange');
}
private handleCameraChanged = (e: IAMapEvent): void => { private handleCameraChanged = (e: IAMapEvent): void => {
const { const {
fov, fov,