Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions packages/maps/src/bmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type {
import { MapServiceEvent } from '@antv/l7-core';
import { DOM } from '@antv/l7-utils';
import { mat4, vec3 } from 'gl-matrix';
import BaseMap from '../lib/base-map';
import Viewport from '../lib/web-mercator-viewport';
import BaseMapService from '../utils/BaseMapService';
import { toPaddingOptions } from '../utils/utils';
import BMapGLLoader from './bmapglloader';
import './logo.css';
Expand All @@ -30,8 +30,7 @@ const EventMap: {

const BMAP_VERSION: string = '1.0';

// TODO: 基于抽象类 BaseMap 实现,补全缺失方法,解决类型问题
export default class BMapService extends BaseMapService<BMapGL.Map> {
export default class BMapService extends BaseMap<BMapGL.Map> {
protected viewport: IViewport;
protected styleConfig: Record<string, any> = {
normal: [],
Expand Down Expand Up @@ -119,7 +118,7 @@ export default class BMapService extends BaseMapService<BMapGL.Map> {
if (mapInstance) {
// @ts-ignore
this.map = mapInstance;
this.$mapContainer = this.map.getContainer();
this.mapContainer = this.map.getContainer();
const point = new BMapGL.Point(center[0], center[1]);
// false,表示用户未执行centerAndZoom进行地图初始渲染
// @ts-ignore
Expand Down Expand Up @@ -147,10 +146,10 @@ export default class BMapService extends BaseMapService<BMapGL.Map> {
let mapChildNodes = [...mapContainer.childNodes];
// @ts-ignore
const map = new BMapGL.Map(mapContainer, mapConstructorOptions);
this.$mapContainer = map.getContainer();
this.mapContainer = map.getContainer();

mapChildNodes.forEach((child) => {
this.$mapContainer!.appendChild(child);
this.mapContainer!.appendChild(child);
});
// @ts-ignore
mapChildNodes = null;
Expand Down Expand Up @@ -271,6 +270,14 @@ export default class BMapService extends BaseMapService<BMapGL.Map> {
return this.map.getMaxZoom();
}

public setMaxZoom(max: number): void {
this.map.setMaxZoom?.(max);
}

public setMinZoom(min: number): void {
this.map.setMinZoom?.(min);
}

// get map params
public getType() {
return 'bmap';
Expand Down Expand Up @@ -323,6 +330,10 @@ export default class BMapService extends BaseMapService<BMapGL.Map> {
return this.getMap().getContainer();
}

public getMapStyle(): string {
return '';
}
Comment thread
lzxue marked this conversation as resolved.

public getMapStyleConfig(): MapStyleConfig {
return this.styleConfig;
}
Expand Down
27 changes: 22 additions & 5 deletions packages/maps/src/tmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import type {
IPoint,
IStatusOptions,
IViewport,
MapStyleConfig,
Point,
} from '@antv/l7-core';
import { MapServiceEvent } from '@antv/l7-core';
import { MercatorCoordinate } from '@antv/l7-map';
import { DOM } from '@antv/l7-utils';
import { mat4, vec3 } from 'gl-matrix';
import BaseMap from '../lib/base-map';
import Viewport from '../lib/web-mercator-viewport';
import BaseMapService from '../utils/BaseMapService';
import { MapTheme } from '../utils/theme';
import './logo.css';
import TMapLoader from './maploader';

Expand All @@ -27,8 +29,7 @@ const EventMap: {
dragging: 'drag',
};

// TODO: 基于抽象类 BaseMap 实现,补全缺失方法,解决类型问题
export default class TMapService extends BaseMapService<TMap.Map> {
export default class TMapService extends BaseMap<TMap.Map> {
// @ts-ignore
protected viewport: IViewport = null;

Expand Down Expand Up @@ -102,7 +103,7 @@ export default class TMapService extends BaseMapService<TMap.Map> {
if (mapInstance) {
// If there's already a map instance, maybe not setting any other configurations
this.map = mapInstance as any;
this.$mapContainer = this.map.getContainer();
this.mapContainer = this.map.getContainer();
if (logoVisible === false) {
this.hideLogo();
}
Expand All @@ -126,7 +127,7 @@ export default class TMapService extends BaseMapService<TMap.Map> {
// @ts-ignore
this.map = map;
// @ts-ignore
this.$mapContainer = map.getContainer();
this.mapContainer = map.getContainer();
if (logoVisible === false) {
this.hideLogo();
}
Expand Down Expand Up @@ -292,6 +293,14 @@ export default class TMapService extends BaseMapService<TMap.Map> {
return this.map.transform._maxZoom;
}

public setMaxZoom(max: number): void {
(this.map as any).setMaxZoom?.(max);
}

public setMinZoom(min: number): void {
(this.map as any).setMinZoom?.(min);
}
Comment thread
lzxue marked this conversation as resolved.

// get map params
public getType() {
return 'tmap';
Expand Down Expand Up @@ -340,6 +349,14 @@ export default class TMapService extends BaseMapService<TMap.Map> {
this.bgColor = color;
}

public getMapStyle(): string {
return '';
}

public getMapStyleConfig(): MapStyleConfig {
return MapTheme;
}

public setMapStyle(styleId: any): void {
this.map.setMapStyleId(styleId);
}
Expand Down
Loading
Loading