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

Class TMapService

packages/maps/src/tmap/map.ts:33–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32// TODO: 基于抽象类 BaseMap 实现,补全缺失方法,解决类型问题
33export default class TMapService extends BaseMapService<TMap.Map> {
34 // @ts-ignore
35 protected viewport: IViewport = null;
36 protected evtCbProxyMap: Map<string, Map<(...args: any) => any, (...args: any) => any>> =
37 new Map();
38
39 public handleCameraChanged = () => {
40 // Trigger map change event
41 this.emit('mapchange');
42 // resync
43 const map = this.map;
44 // @ts-ignore
45 const { lng, lat } = map.getCenter();
46 const option = {
47 center: [lng, lat],
48 // @ts-ignore
49 viewportHeight: map.getContainer().clientHeight,
50 // @ts-ignore
51 viewportWidth: map.getContainer().clientWidth,
52 // @ts-ignore
53 bearing: map.getHeading(),
54 // @ts-ignore
55 pitch: map.getPitch(),
56 // @ts-ignore
57 zoom: map.getZoom() - 1,
58 };
59
60 this.viewport.syncWithMapCamera(option as any);
61 this.updateCoordinateSystemService();
62 this.cameraChangedCallback(this.viewport);
63 };
64
65 public async init(): Promise<void> {
66 this.viewport = new Viewport();
67
68 // TODO: Handle initial config
69 const {
70 id,
71 mapInstance,
72 center = [121.30654632240122, 31.25744185633306],
73 token = TMAP_API_KEY,
74 version = BMAP_VERSION,
75 libraries = [],
76 minZoom = 3,
77 maxZoom = 18,
78 rotation = 0,
79 pitch = 0,
80 mapSize = 10000,
81 logoVisible = true,
82 ...rest
83 } = this.config;
84
85 if (!(window.TMap || mapInstance)) {
86 await TMapLoader.load({
87 key: token,
88 version,
89 libraries,
90 });

Callers

nothing calls this directly

Calls 6

emitMethod · 0.65
getCenterMethod · 0.65
getContainerMethod · 0.65
getPitchMethod · 0.65
getZoomMethod · 0.65
syncWithMapCameraMethod · 0.65

Tested by

no test coverage detected