Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development API geo-location constructor


May 20, 2021 WeChat Mini Program Development Document


Table of contents


Db. Geo

The object contains a geo-location constructor.

The owning fields are as follows:

Field Description
Point Location point

Db. Geo.Point

Construct a geographic location. Can be used to query criteria, update field values, or add field values when records are added.

The method signature is as follows:

function Point(longitude: number, latitude: number): Point

Method accepts two required parameters, the first is longitude and the second is latitude, so it is important to pay attention to the order

The sample code

const db = wx.cloud.database()
db.collection('todos').add({
  description: 'eat an apple',
  location: db.Geo.Point(113, 23)
})