MCPcopy
hub / github.com/antvis/L7 / BMapService

Class BMapService

packages/maps/src/bmap/map.ts:35–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34// TODO: 基于抽象类 BaseMap 实现,补全缺失方法,解决类型问题
35export default class BMapService extends BaseMapService<BMapGL.Map> {
36 protected viewport: IViewport;
37 protected styleConfig: Record<string, any> = {
38 normal: [],
39 };
40 protected currentStyle: any = 'normal';
41 // 事件回调代理
42 protected evtCbProxyMap: Map<string, Map<(...args: any) => any, (...args: any) => any>> =
43 new Map();
44
45 public getMap() {
46 return this.map as any as BMapGL.Map & {
47 destroy: () => void;
48 getTilt: () => number;
49 enableRotate: () => void;
50 enableRotateGestures: () => void;
51 disableRotate: () => void;
52 disableRotateGestures: () => void;
53 lnglatToMercator: (lng: number, lat: number) => [number, number];
54 _webglPainter: {
55 _canvas: HTMLCanvasElement;
56 };
57 getHeading: () => number;
58 setDisplayOptions: (options: { indoor?: boolean }) => void;
59 };
60 }
61
62 public handleCameraChanged = () => {
63 this.emit('mapchange');
64 const map = this.getMap();
65 const { lng, lat } = map.getCenter();
66 const option = {
67 center: [lng, lat],
68 viewportHeight: map.getContainer().clientHeight,
69 viewportWidth: map.getContainer().clientWidth,
70 bearing: 360 - map.getHeading(),
71 pitch: map.getTilt(),
72 zoom: map.getZoom() - 1.75,
73 };
74 this.viewport.syncWithMapCamera(option as any);
75 this.updateCoordinateSystemService();
76 this.cameraChangedCallback(this.viewport);
77 };
78
79 public setBgColor(color: string): void {
80 this.bgColor = color;
81 }
82
83 public async init() {
84 this.viewport = new Viewport();
85 const {
86 id,
87 center = [121.30654632240122, 31.25744185633306],
88 zoom = 12,
89 token = BMAP_API_KEY,
90 mapInstance,
91 version = BMAP_VERSION,
92 mapSize = 10000,

Callers

nothing calls this directly

Calls 6

getMapMethod · 0.95
emitMethod · 0.65
getCenterMethod · 0.65
getContainerMethod · 0.65
getZoomMethod · 0.65
syncWithMapCameraMethod · 0.65

Tested by

no test coverage detected