Skip to content

isCoordInRegion

isCoordInRegion(options): Promise<boolean>

判断给定坐标是否在某地

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

参数

NameTypeDescription
optionsObject
options.latitudenumber纬度
options.longitudenumber经度
options.regionCodestring区域码

返回值

Promise<boolean>

示例

js
const location = await uni.getLocation()

// 判断当前坐标在是否处于广东省
isCoordInRegion({...location, regionCode: '440000'})

// 判断当前坐标在是否处于广东省广州市
isCoordInRegion({...location, regionCode: '440100'})

// 判断当前坐标在是否处于广东省广州市海珠区
isCoordInRegion({...location, regionCode: '440105'})

源码

geojson.js