Skip to content

Commit

Permalink
fix: 高德地图底图模式,事件交互注册顺序的问题导致不生效
Browse files Browse the repository at this point in the history
  • Loading branch information
lzxue committed Dec 26, 2019
1 parent a936d97 commit 2ad4289
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/services/scene/SceneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/core/triangulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) {
indices: index,
normals,
// normals: Array.from(computeVertexNormals(positions, index, 3, false)),
size: 3,
size: 5,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/maps/src/amap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
95 changes: 47 additions & 48 deletions stories/Layers/components/Point.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
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);
// 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);
});
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);
});

this.scene = scene;
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() {
Expand Down

0 comments on commit 2ad4289

Please sign in to comment.