diff --git a/docs/geocode.md b/docs/geocode.md new file mode 100644 index 0000000..2870b0b --- /dev/null +++ b/docs/geocode.md @@ -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` +- `address`: 应该是与传进来的地址是一样的 +- `latitude`: 转换之后的经度 +- `longitude`: 转换之后的经度 + +### `reverse(coordinate: LatLng): Promise` +逆地理编码,坐标 -> 地址 + +#### `ReverseResult` +- `latitude`: 应该与传进来的经度是一样的 +- `longitude`: 应该与传进来的纬度是一样的 +- `country`: 国家 +- `countryCode`: 国家代码 +- `province`: 省/直辖市 +- `city`: 城市 +- `cityCode`: 城市代码 +- `district`: 城区 +- `street`: 街道 +- `streetNumber`: 街道编号 +- `businessCircle`: 商圈 +- `adCode`: 邮政编码 +- `address`: 完整地址 +- `description`: 语义化描述 \ No newline at end of file diff --git a/docs/location.md b/docs/location.md index 852f42e..6af759e 100644 --- a/docs/location.md +++ b/docs/location.md @@ -4,6 +4,8 @@ 用法: ```javascript +import { Location } from 'react-native-baidumap-sdk' + await Location.init() Location.addLocationListener(location => console.log(location)) Location.start() @@ -31,9 +33,9 @@ Location.start() 添加监听函数 #### `Result` -- `latitude: number` 经度 -- `longitude: number` 纬度 -- `accuracy: number` 精度 -- `altitude: number` 海拔 -- `speed: number` 速度 -- `direction: number` 方向 \ No newline at end of file +- `latitude`: 经度 +- `longitude`: 纬度 +- `accuracy`: 精度 +- `altitude`: 海拔 +- `speed`: 速度 +- `direction`: 方向 \ No newline at end of file diff --git a/lib/js/modules/geocode.js b/lib/js/modules/geocode.js index 67ec56d..70fba7a 100644 --- a/lib/js/modules/geocode.js +++ b/lib/js/modules/geocode.js @@ -22,7 +22,7 @@ type ReverseResult = { } & LatLng export default { - search(address: string, city: string) : Promise { + search(address: string, city: string = '') : Promise { return BaiduMapGeocode.search(address, city) }, reverse(coordinate: LatLng) : Promise { diff --git a/package.json b/package.json index f04f9c5..b10f11a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "location", "baidumap" ], - "version": "0.2.0", + "version": "0.3.0", "author": "7c00 ", "repository": { "type": "git", diff --git a/readme.md b/readme.md index 07a6879..f4a6025 100644 --- a/readme.md +++ b/readme.md @@ -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