Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/z41z/sp-bmap
- Owner: z41z
- License: bsd-2-clause
- Created: 2018-12-07T01:45:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T19:10:24.000Z (almost 2 years ago)
- Last Synced: 2023-03-02T03:41:52.942Z (over 1 year ago)
- Topics: baidumap, bmap, map
- Language: JavaScript
- Homepage:
- Size: 863 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)