Appearance
getRegionByCoord
▸ getRegionByCoord(options
): Promise
<any
>
根据经纬度判断用户属于哪个区域,可通过 regionCode 指定查询区域
fetch url: ${host}/geojson/bound/${regionCode}-full.json
参数
Name | Type | Description |
---|---|---|
options | Object | |
options.format | undefined | (feature : Feature ) => any | 返回的数据格式,默认只返回 region code |
options.latitude | number | 纬度 |
options.longitude | number | 经度 |
options.regionCode | string | 上级区域码 |
返回值
Promise
<any
>
示例
js
const location = await uni.getLocation()
// 判断当前坐标在广东省内哪座城市
getRegionByCoord({...location, regionCode: '440000'})
// 判断当前坐标在广州市内哪个区
getRegionByCoord({...location, regionCode: '440100'})