-
Notifications
You must be signed in to change notification settings - Fork 37
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
Showing
166 changed files
with
18,763 additions
and
6,767 deletions.
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,10 @@ | ||
{ | ||
"presets": [ | ||
"es2015", | ||
"react", | ||
"stage-0" | ||
], | ||
"plugins": [ | ||
"transform-decorators-legacy" | ||
] | ||
} |
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,48 @@ | ||
module.exports = { | ||
title: 'rc-bmap', | ||
description: '像使用React组件一样使用百度地图', | ||
themeConfig: { | ||
nav: [ | ||
{ text: '指南', link: '/guide/' }, | ||
{ text: 'API', link: '/api/' }, | ||
{ text: '示例', link: '/demo/' }, | ||
{ text: 'GitHub', link: 'https://github.com/JserWang/rc-bmap' }, | ||
], | ||
sidebar: { | ||
'/guide/': getSiderbarConfig('指南'), | ||
'/api/': getApiSiderbarConfig('API'), | ||
} | ||
} | ||
} | ||
|
||
function getSiderbarConfig(title) { | ||
return [ | ||
{ | ||
title, | ||
collapsable: false, | ||
children: [ | ||
'getting-started', | ||
'', | ||
'map', | ||
'control', | ||
'overlay', | ||
'route', | ||
'lib', | ||
'other', | ||
'constants', | ||
] | ||
} | ||
] | ||
} | ||
|
||
function getApiSiderbarConfig(title) { | ||
return [ | ||
{ | ||
title, | ||
collapsable: false, | ||
children: [ | ||
'', | ||
] | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
--- | ||
home: true | ||
heroImage: /home.png | ||
actionText: 快速上手 → | ||
actionLink: /guide/getting-started | ||
features: | ||
- title: 基于BaiduMap | ||
details: 所有BaiduMap提供的API在这里你都能使用。 | ||
- title: 组件化 | ||
details: 就像使用React组件一样使用它。 | ||
- title: 提供常用组件 | ||
details: 覆盖部分业务场景,引入即用。 | ||
footer: MIT Licensed | Copyright © 2018-present JserWang | ||
--- | ||
|
||
### 还原你最熟悉的方式 | ||
|
||
``` js | ||
<Map | ||
ak={...} | ||
> | ||
<Polyline /> | ||
<Control /> | ||
</Map> | ||
``` |
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,147 @@ | ||
# Map | ||
|
||
## ak | ||
* 类型 string | ||
* 默认值 "" | ||
* 描述 加载地图时所需ak | ||
|
||
## placeHolder | ||
* 类型 string 或 ReactElement | ||
* 默认值 "地图加载中..." | ||
* 描述 地图未加载完成时,展示内容 | ||
|
||
## mapMounted | ||
* 类型 Function | ||
* 默认值 null | ||
* 描述 地图渲染完成后回调函数 | ||
|
||
## minZoom | ||
* 类型 number | ||
* 默认值 3 | ||
* 描述 地图允许的最小级别,取值不得小于地图类型所允许的最小级别 | ||
|
||
## maxZoom | ||
* 类型 number | ||
* 默认值 19 | ||
* 地图允许的最大级别。取值不得大于地图类型所允许的最大级别 | ||
|
||
## defaultCursor | ||
* 类型 string | ||
* 默认值 "" | ||
* 描述 设置地图默认的鼠标指针样式。参数cursor应符合CSS的cursor属性规范 | ||
|
||
## draggingCursor | ||
* 类型 string | ||
* 默认值 "" | ||
* 描述 设置拖拽地图时的鼠标指针样式。参数cursor应符合CSS的cursor属性规范 | ||
|
||
## mapStyle | ||
* 类型 Object | ||
* 默认值 {} | ||
* 描述 设置地图样式,样式包括地图底图颜色和地图要素是否展示两部分 | ||
|
||
若您使用[百度地图个性化模板时](http://lbsyun.baidu.com/custom/list.htm),可传递如下值: | ||
|
||
``` js | ||
{ | ||
style: 'midnight' | ||
} | ||
``` | ||
|
||
若您使用[百度地图图形编辑工具](http://lbsyun.baidu.com/img-editor.html),可传递如下值: | ||
|
||
``` js | ||
{ | ||
styleJson: mapStyle, | ||
} | ||
``` | ||
|
||
## center | ||
* 类型 Object | ||
* 默认值 { lng: 116.404, lat: 39.915 } | ||
* 描述 设初始化地图中心点,默认值为 { lng: 116.404, lat: 39.915 } | ||
|
||
## mapType | ||
* 类型 Enum | ||
* 默认值 [MapType](/guide/constants.html#maptype).NORMAL | ||
* 描述 设置地图类型 | ||
|
||
## zoom | ||
* 类型 number | ||
* 默认值 15 | ||
* 描述 将视图切换到指定的缩放等级,中心点坐标不变。 | ||
|
||
## highResolution | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否启用使用高分辨率地图 | ||
|
||
## autoResize | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否自动适应地图容器变化 | ||
|
||
## mapClick | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否开启底图可点功能 | ||
|
||
## dragging | ||
* 类型 boolean | ||
* 默认值 true | ||
> 是否启用地图拖拽 | ||
## scrollWheelZoom | ||
* 类型 boolean | ||
* 默认值 false | ||
* 描述 是否启用滚轮放大缩小 | ||
|
||
## doubleClickZoom | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否启用双击放大 | ||
|
||
## keyboard | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否启用键盘操作 | ||
|
||
## inertialDragging | ||
* 类型 boolean | ||
* 默认值 false | ||
* 描述 是否启用地图惯性拖拽 | ||
|
||
## continuousZoom | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否启用连续缩放效果 | ||
|
||
## pinchToZoom | ||
* 类型 boolean | ||
* 默认值 true | ||
* 描述 是否启用双指操作缩放 | ||
|
||
## events | ||
* 类型 Object | ||
* 默认值 null | ||
* 描述 为地图[绑定事件]((http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference_3_0.html#a0b0) | ||
|
||
## contextMenu | ||
* 类型 Object | ||
* 默认值 null | ||
* 描述 为地图设置右键菜单 | ||
|
||
传入属性需为`ContextMenu`字面量值,如: | ||
``` js | ||
{ | ||
items: [{ | ||
text: '放大', | ||
callback: function() {global.bMapInstance.zoomIn()}, | ||
}, | ||
{ | ||
text: '缩小', | ||
callback: function() {global.bMapInstance.zoomOut()}, | ||
separator: true, | ||
}] | ||
} | ||
``` |
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,110 @@ | ||
# 介绍 | ||
|
||
## 初衷 | ||
rc-bmap源于一次业务对百度地图相关的需求,由于前端技术栈使用的是React,官方仅提供了最基础的js,使用起来很不React。现有github中的React版百度地图方式无法满足需求,所以决定来一次愉快的封装。 | ||
|
||
## 起步 | ||
::: danger | ||
在开始之前,希望您对[React](https://reactjs.org/docs/getting-started.html)与[百度地图](http://lbsyun.baidu.com/index.php?title=jspopular3.0)已经有了一定的了解 | ||
::: | ||
|
||
``` js | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Map } from 'rc-bmap'; | ||
|
||
render(<Map ak="WAeVpuoSBH4NswS30GNbCRrlsmdGB5Gv" />, | ||
document.getElementById('app') | ||
); | ||
|
||
``` | ||
|
||
::: warning 注意: | ||
1. 在使用时,您需要自行替换您自己在百度所申请的AK值,目前AK仅作demo示例使用。 | ||
2. 此处,div#app的高度与宽度均为100%,若无相关高度定义时,百度地图将渲染在一个高度为0的容器中。 | ||
::: | ||
|
||
## 添加控件 | ||
|
||
``` js | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Map, Navigation } from 'rc-bmap'; | ||
|
||
render( | ||
<Map ak="WAeVpuoSBH4NswS30GNbCRrlsmdGB5Gv"> | ||
{/* 在Map中添加控件 */} | ||
<Navigation /> | ||
</Map>, | ||
document.getElementById('app') | ||
); | ||
|
||
``` | ||
|
||
## 添加覆盖物 | ||
|
||
``` js | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Map, Marker } from 'rc-bmap'; | ||
|
||
const markerPoint = { | ||
lng: 116.404, | ||
lat: 39.915, | ||
}; | ||
|
||
render( | ||
<Map ak="WAeVpuoSBH4NswS30GNbCRrlsmdGB5Gv"> | ||
{/* 在Map中添加覆盖物 */} | ||
<Marker point={markerPoint} /> | ||
</Map>, | ||
document.getElementById('app') | ||
); | ||
|
||
``` | ||
|
||
## 自定义控件与自定义覆盖物 | ||
|
||
在这里,我们为您提供了两个基础类,分别为`Control`与`Overlay`,您可以通过继承后,实现`render`方法即可呈现。 | ||
|
||
您自定义的控件与覆盖物,均可使用其父类的属性、事件、方法,与此同时,还为您提供了`state`与`setState`这对基友,方便您在内部通过更改状态即可完成对视图的重新渲染。 | ||
|
||
### 自定义控件 | ||
|
||
``` js | ||
import React from 'react'; | ||
import { ReactComponent, Control } from 'rc-bmap'; | ||
|
||
@ReactComponent | ||
class CustomControl extends Control { | ||
render() { | ||
return ( | ||
<div>这是一个自定义控件</div> | ||
) | ||
} | ||
} | ||
|
||
export default CustomControl; | ||
|
||
``` | ||
|
||
### 自定义覆盖物 | ||
``` js | ||
import React from 'react'; | ||
import { ReactComponent, Overlay } from 'rc-bmap'; | ||
|
||
@ReactComponent | ||
class CustomOverlay extends Overlay { | ||
render() { | ||
return ( | ||
<div>这是一个自定义覆盖物</div> | ||
) | ||
} | ||
} | ||
|
||
export default CustomOverlay; | ||
|
||
``` | ||
|
||
## 感兴趣吗? | ||
如果你对以上内容兴趣,那么请继续往下浏览各组件的使用方法吧。 |
Oops, something went wrong.