Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/z41z/sp-bmap

Common Map functions based on Baidu Map
https://github.com/z41z/sp-bmap

baidumap bmap map

Last synced: 4 days ago
JSON representation

Common Map functions based on Baidu Map

Awesome Lists containing this project

README

        

# sp-map

Common Map methods

## Usage

- ### init

- ### CDN

``` html






sp-bmap

#map {
width: 100vw;
height: 100vh;
}





<script src="https://unpkg.com/sp-bmap/dist/index.min.js">
window.onload = function () {
var map = __Map.map.init("map");
}


```

- ### NPM

``` node
npm i sp-bmap //or yarn add sp-bmap
```

``` js

let __Map = require("sp-bmap");
```

- ### map

- init(elementId, [lng = 0, lat =0, zoomLevel = 3])

``` js
__Map.map.init("map", lng, lat, zoomLevel);
```

- center([point = (lng = 0, lat = 0)])

``` js
let point = __Map.point(lng, lat);
__Map.map.center(point);
```

- zoom([zoomLevel = 3])

``` js
__Map.map.zoom(12);
```

- scroll([isScroll = true])

```js
__Map.map.scroll(false);
```

- moveTo(lng, lat)

```js
__Map.map.moveTo(106, 26);
```

- ### point([lng = 0, lat = 0])

``` js
__Map.point(lng, lat);
```

- ### polygon

- #### egg(radius, [level = 1, lng = 0, lat = 0, options = {}, rotateDegree = 0])

``` js
let map = __Map.map.init("map", 110, 30, 16)
let marker = new BMap.Marker(__Map.point(104.075277, 30.548096))
map.addOverlay(marker)

let polygonOptions = {
fillColor: '#f00',
fillOpacity: .3,
strokeWeight: 1,
strokeOpacity: .3
}
let radius = [100, 300, 800]
radius.forEach(r=>{
let egg = __Map.polygon.egg(r, 1, 104.075277, 30.548096, polygonOptions)
map.addOverlay(egg);
})
```

![egg](./static/polygon_egg.png)