Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 地图类型新增对百度和腾讯地图的支持 #194

Merged
merged 1 commit into from
Nov 6, 2023
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
11 changes: 11 additions & 0 deletions src/components/LarkMap/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export const createMap = async (mapType: LarkMapProps['mapType'], mapOptions: Pa
return new GaodeMapV2(mapOptions);
}

if (mapType === 'Tencent') {
return Promise.resolve(import('@antv/l7')).then(({ TencentMap }) => {
return new TencentMap(mapOptions);
});
}
if (mapType === 'Baidu') {
return Promise.resolve(import('@antv/l7')).then(({ BaiduMap }) => {
return new BaiduMap(mapOptions);
});
}

return Promise.resolve(import('@antv/l7')).then(({ Mapbox }) => {
return new Mapbox(mapOptions);
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/LarkMap/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nav:

### 介绍

LarkMap 是地图容器组件,相关地图组件与 Hooks 需放到容器组件内部才能使用,容器组件可通过属性配置不同的地图,支持 [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)、[Gaode](https://lbs.amap.com/api/jsapi-v2/documentation#map) 及 [L7Map](https://l7.antv.antgroup.com/api/map) 作为底图。
LarkMap 是地图容器组件,相关地图组件与 Hooks 需放到容器组件内部才能使用,容器组件可通过属性配置不同的地图,支持 [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)、[Gaode](https://lbs.amap.com/api/jsapi-v2/documentation#map)、[Baidu](https://mapopen-pub-jsapi.bj.bcebos.com/jsapi/reference/jsapi_webgl_1_0.html#a0b0)、[Tencent](https://lbs.qq.com/webApi/javascriptGL/glDoc/docIndexMap) 及 [L7Map](https://l7.antv.antgroup.com/api/map) 作为底图,其中 [Baidu](https://mapopen-pub-jsapi.bj.bcebos.com/jsapi/reference/jsapi_webgl_1_0.html#a0b0) 和 [Tencent](https://lbs.qq.com/webApi/javascriptGL/glDoc/docIndexMap) 仍为实验特性

### 代码演示

Expand All @@ -34,7 +34,7 @@ LarkMap 是地图容器组件,相关地图组件与 Hooks 需放到容器组
| style | 容器行内样式 | `CSSProperties` | -- |
| className | 容器类名 | `string` | -- |
| map | 地图实例,可选,也可以通过配置项自动生成实例,详见 [L7 map](https://l7.antv.antgroup.com/api/map/map) | `MapInstance | (() => Promise<IMapWrapper>)` | -- |
| mapType | 地图底图类型 | `'Gaode'|`<br />`'GaodeV2'|`<br />`'Mapbox'|`<br />`'Map'` | `'Gaode'` |
| mapType | 地图底图类型 | `'Gaode'|`<br />`'GaodeV2'|`<br />`'Mapbox'|`<br />`'Map'|`<br />`'Tencent'|`<br />`'Baidu'` | `'Gaode'` |
| mapOptions | 地图配置项,配合地图类型配置地图,详情可见 [MapOptions](#mapoptions) | `MapOptions` | -- |
| logoPosition | logo 展示位置,配置项详见 [L7 logoPosition](https://l7.antv.antgroup.com/api/scene#logoposition) | `PositionName` | `'bottomleft'` |
| logoVisible | 是否显示 logo | `boolean` | `true` |
Expand Down
2 changes: 1 addition & 1 deletion src/components/LarkMap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface LarkMapProps extends CommonProps, Omit<ISceneConfig, 'id' | 'ca
* 地图类型
* @default 'Gaode'
*/
mapType?: 'Gaode' | 'GaodeV1' | 'GaodeV2' | 'Mapbox' | 'Map';
mapType?: 'Gaode' | 'GaodeV1' | 'GaodeV2' | 'Mapbox' | 'Map' | 'Tencent' | 'Baidu';
/**
* 地图配置项
* 配合地图类型配置地图,
Expand Down
Loading