当前位置:网站首页>小程序已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
小程序已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
2022-07-28 01:59:00 【CSDN问答】
小程序 已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
自己搞几天了,还是不行,求指点、求帮助。
async onLoad(options) { // 查询一个集合中所有记录 const db = wx.cloud.database() let count = await db.collection('menDian').count() count = count.total let all =[] for (let i=0;i<count;i+=20){ let list = await db.collection('menDian').skip(i).get() all = all.concat(list.data); } console.log(all) // 获取用户位置 wx.getLocation({ type: 'wgs84', success (res) { console.log(res) const latitude = res.latitude const longitude = res.longitude // 由近到远排列,这里搞不懂了 db.collection('mendian').aggregate() .geoNear({ distanceField: 'this.menDianXinXi.item.jingweidu', // 输出的每个记录中 distance 即是与给定点的距离 spherical: true, near: db.Geo.Point(longitude,latitude), }).end() .then(res =>{ console.log(res) }) },边栏推荐
- First knowledge of C language -- operators and keywords, define, pointer
- Arm32 for remote debugging
- IO流:节点流和处理流详细归纳。
- Pytest the best testing framework
- 入职华为od一个月的感受
- A 64 bit 8-stage pipelined adder based on FPGA
- 1313_ Pyserial installation and document generation
- Canvas from getting started to persuading friends to give up (graphic version)
- [software testing] - unittest framework for automated testing
- [brother hero's July training] day 26: check the collection
猜你喜欢

分层图解决的一些最短路问题

How do you use the jar package sent by others (how to use the jar package sent by others)

Center-based 3D Object Detection and Tracking(基于中心的3D目标检测和跟踪 / CenterPoint)论文笔记

Typescript (zero) -- introduction, environment construction, first instance

新基建助力智能化道路交通领域的转型发展

Selenium+pytest+allure comprehensive exercise

How do gateways and chirpstacks in lorawan communicate? UDP? GRPC? MQTT?

mysql 如图所示,现有表a,表b,需求为 通过projectcode关联a、b表,查出address不同的 idcardnum。

pytest最好的测试框架

【LeetCode】13. Linked List Cycle·环形链表
随机推荐
JS中的reduce()函数介绍
Notes for the fourth time of first knowing C language
trivy【1】工具扫描运用
JS 事件对象2 e.charcode字符码 e.keyCode键码 盒子上下左右移动
POC simulation attack weapon - Introduction to nucleus (I)
【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
没法预测明天的涨跌
分层图解决的一些最短路问题
Digital twin agriculture - Smart agriculture rice processing plant has changed from "watching the sky to eat" to "knowing the sky to work"
[brother hero's July training] day 27: picture
软件产品第三方测试费用为什么没有统一的报价?
Typescript (zero) -- introduction, environment construction, first instance
Data center construction (III): introduction to data center architecture
Selenium+pytest+allure comprehensive exercise
Gbase8s how to delete data in a table with a foreign key relationship
windbg
Flutter神操作学习之(满级攻略)
On the problem that sqli labs single quotation marks do not report errors
JS event object 2 e.charcode character code e.keycode key code box moves up, down, left and right
RTSP/Onvif协议EasyNVR视频平台一键升级方案的开发设计逻辑