Skip to content

getRegionByCoord

getRegionByCoord(options): Promise<any>

根据经纬度判断用户属于哪个区域,可通过 regionCode 指定查询区域

fetch url: ${host}/geojson/bound/${regionCode}-full.json

参数

NameTypeDescription
optionsObject
options.formatundefined | (feature: Feature) => any返回的数据格式,默认只返回 region code
options.latitudenumber纬度
options.longitudenumber经度
options.regionCodestring上级区域码

返回值

Promise<any>

示例

js
const location = await uni.getLocation()

// 判断当前坐标在广东省内哪座城市
getRegionByCoord({...location, regionCode: '440000'})

// 判断当前坐标在广州市内哪个区
getRegionByCoord({...location, regionCode: '440100'})

源码

geojson.js