-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
daiwanxing
committed
Jan 24, 2023
1 parent
e840c5b
commit 98d611e
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# BMap-loader | ||
|
||
BMap-loader 是一个非官方的地图 jsAPI 加载器, 目标是为用户提供一个简洁易用的创建百度地图的插件。 BMap-loader 的灵感来源于 [amap-jsapi-loader](https://www.npmjs.com/package/@amap/amap-jsapi-loader), 但目前仍有部分功能待实现中, 如果您愿意贡献代码,欢迎提 PR。 | ||
|
||
BMap-loader 特性如下: | ||
|
||
- 支持以 UMD 和 ESM 两种方式使用; | ||
- 以异步加载的方式加载百度地图; | ||
- 支持同时加载 JSAPI JSAPI-GL 两个地图版本; | ||
- 支持多次加载插件; | ||
- 对于加载地图的错误用法给予报错处理; | ||
|
||
# 使用方式 | ||
|
||
## 以 npm 方式引用 | ||
|
||
```shell | ||
$ npm install bmap-loader --save | ||
``` | ||
|
||
```js | ||
import BMapLoader from "bmap-loader"; | ||
|
||
BMapLoader({ | ||
v: "1.0", | ||
type: "webgl", | ||
ak: "填写你的ak密钥", | ||
}).then((BMapGL) => { | ||
const map = new BMapGL.Map("map"); | ||
map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 11); | ||
map.addControl( | ||
new BMapGL.MapTypeControl({ | ||
mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP], | ||
}) | ||
); | ||
map.enableScrollWheelZoom(true); | ||
}); | ||
``` | ||
|
||
## 以 js 脚本的方式引用 | ||
|
||
```html | ||
<script src="../dist/bmap-loader.umd.js"></script> | ||
<script> | ||
BMapLoader({ | ||
v: "1.0", | ||
type: "webgl", | ||
ak: "填写你的ak密钥", | ||
}).then((BMapGL) => { | ||
const map = new BMapGL.Map("map"); | ||
map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 11); | ||
map.addControl( | ||
new BMapGL.MapTypeControl({ | ||
mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP], | ||
}) | ||
); | ||
map.enableScrollWheelZoom(true); | ||
}); | ||
</script> | ||
``` | ||
|
||
## RoadMap | ||
|
||
- [ ] 改用 typescript 重写,增强智能提示。 | ||
- [ ] 支持加载百度地图的插件库。 | ||
|
||
# License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters