当前位置:K88软件开发文章中心编程全书微信小程序 → 文章内容

微信小程序云开发服务端数据库API 地理位置构造器

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:03:27

由 Carrie 创建, 最后一次修改 2018-11-15 db.Geo该对象上含有地理位置构造器。拥有字段如下:字段说明Point地理位置点db.Geo.Point构造一个地理位置点。可用于查询条件、更新字段值或新增记录时的字段值。方法签名如下:function Point(longitude: number, latitude: number): Point方法接受两个必填参数,第一个是经度(longitude),第二个是纬度(latitude),务必注意顺序示例代码const cloud = require('wx-server-sdk')cloud.init()const db = cloud.database()exports.main = async (event, context) => { try { return await db.collection('todos').add({ description: 'eat an apple', location: new db.Geo.Point(113, 23) }) } catch(e) { console.error(e) }}

微信小程序云开发服务端数据库API 地理位置构造器