半径需以弧度计,比如需要 10km 的半径,则用距离除以地球半径 6378.1km 得出的数字。
const _ = db.command
db.collection('restaurants').where({
location: _.geoWithin({
centerSphere: [
[-88, 30],
10 / 6378.1,
]
})
})
Command.geoIntersects(options: Object): Command
支持端:小程序 , 云函数 , Web找出给定的地理位置图形相交的记录
参数
options: Object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
geometry | Object | 是 | 地理信息结构,Point |
返回值
Command
索引要求
需对查询字段建立地理位置索引
示例代码:找出和一个多边形相交的记录
const _ = db.command
const { Point, LineString, Polygon } = db.Geo
db.collection('restaurants').where({
location: _.geoIntersects({
geometry: Polygon([
LineString([
Point(0, 0),
Point(3, 2),
Point(2, 3),
Point(0, 0)
])
]),
})
})
标签:微信小程序
相关阅读 >>
微信小程序api 音频-inneraudiocontext对象
微信小程序api 用户信息 wx.getuserinfo(object)
更多相关阅读请进入《微信小程序》频道 >>

Vue.js 设计与实现 基于Vue.js 3 深入解析Vue.js 设计细节
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者