Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Feb 20, 2018
1 parent fab6faf commit 2a7462b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
41 changes: 41 additions & 0 deletions docs/geocode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Geocode 地理编码/逆编码模块


```javascript
import { Geocode } from 'react-native-baidumap-sdk'

// 地理编码,也就是地址 -> 坐标
const searchResult = await Geocode.search('海龙大厦', '北京市')

// 逆地理编码,也就是坐标 -> 地址
const reverseResult = await Geocode.reverse({ latitude: 39, longitude: 113 })
```

## Methods

### `search(address: string, city: string = ''): Promise<SearchResult>`
地理编码,地址 -> 坐标

#### `SearchResult`
- `address`: 应该是与传进来的地址是一样的
- `latitude`: 转换之后的经度
- `longitude`: 转换之后的经度

### `reverse(coordinate: LatLng): Promise<ReverseResult>`
逆地理编码,坐标 -> 地址

#### `ReverseResult`
- `latitude`: 应该与传进来的经度是一样的
- `longitude`: 应该与传进来的纬度是一样的
- `country`: 国家
- `countryCode`: 国家代码
- `province`: 省/直辖市
- `city`: 城市
- `cityCode`: 城市代码
- `district`: 城区
- `street`: 街道
- `streetNumber`: 街道编号
- `businessCircle`: 商圈
- `adCode`: 邮政编码
- `address`: 完整地址
- `description`: 语义化描述
14 changes: 8 additions & 6 deletions docs/location.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

用法:
```javascript
import { Location } from 'react-native-baidumap-sdk'

await Location.init()
Location.addLocationListener(location => console.log(location))
Location.start()
Expand Down Expand Up @@ -31,9 +33,9 @@ Location.start()
添加监听函数

#### `Result`
- `latitude: number` 经度
- `longitude: number` 纬度
- `accuracy: number` 精度
- `altitude: number` 海拔
- `speed: number` 速度
- `direction: number` 方向
- `latitude`: 经度
- `longitude`: 纬度
- `accuracy`: 精度
- `altitude`: 海拔
- `speed`: 速度
- `direction`: 方向
2 changes: 1 addition & 1 deletion lib/js/modules/geocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ReverseResult = {
} & LatLng

export default {
search(address: string, city: string) : Promise<SearchResult> {
search(address: string, city: string = '') : Promise<SearchResult> {
return BaiduMapGeocode.search(address, city)
},
reverse(coordinate: LatLng) : Promise<ReverseResult> {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"location",
"baidumap"
],
"version": "0.2.0",
"version": "0.3.0",
"author": "7c00 <[email protected]>",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ render() {
- [Marker](docs/marker.md)
- [Polygon](docs/polygon.md)
- [Location](docs/location.md)
- [Geocode](docs/geocode.md)

[npm]: https://www.npmjs.com/package/react-native-baidumap-sdk
[version-badge]: https://badge.fury.io/js/react-native-baidumap-sdk.svg
Expand Down

0 comments on commit 2a7462b

Please sign in to comment.