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

Class BMapService

packages/maps/src/amap-next/map.ts:31–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31export default class BMapService extends BaseMap<AMap.Map> {
32 protected viewport = new Viewport();
33
34 public version = MapType.GAODE;
35
36 public getType() {
37 return 'amap';
38 }
39
40 public async init() {
41 const {
42 id,
43 style = 'light',
44 minZoom = 0,
45 maxZoom = 24,
46 token = AMAP_API_KEY,
47 mapInstance,
48 plugin = [],
49 ...rest
50 } = this.config;
51
52 if (!(window.AMap || mapInstance)) {
53 plugin.push('Map3D');
54 await AMapLoader.load({
55 key: token, // 申请好的Web端开发者Key,首次调用 load 时必填
56 version: AMAP_VERSION, // 指定要加载的 JSAPI 的版本
57 plugins: plugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
58 });
59 }
60
61 if (mapInstance) {
62 this.map = mapInstance;
63 this.mapContainer = this.map.getContainer();
64
65 this.map.on('viewchange', this.handleCameraChanged);
66 } else {
67 const mapConstructorOptions: AMap.Map.Options = {
68 mapStyle: this.getMapStyleValue(style as string),
69 // 默认取值范围 [2, 20]
70 zooms: [minZoom, maxZoom],
71 viewMode: '3D',
72 ...rest,
73 // 地图平移过程中是否使用动画(如调用 panBy、panTo、setCenter、setZoomAndCenter 等函数, 将对地图产生平移操作, 是否使用动画平移的效果), 默认为 true , 即使用动画
74 // animateEnable: false,
75 // 地图使用缓动效果
76 // jogEnable: false,
77 };
78
79 if (mapConstructorOptions.zoom) {
80 // 高德地图在相同大小下需要比 MapBox 多一个 zoom 层级
81 mapConstructorOptions.zoom += ZOOM_OFFSET;
82 }
83
84 if (token === AMAP_API_KEY) {
85 (window as any)._AMapSecurityConfig = {
86 securityJsCode: '2653011adeb04230b3a26cc9a780a800',
87 };
88 console.warn(

Callers

nothing calls this directly

Calls 2

getViewStateMethod · 0.95
updateViewMethod · 0.80

Tested by

no test coverage detected