# Geo.Point(longitude: number, latitude: number): GeoPoint

支持端:小程序 , 云函数 , Web

构造一个地理位置 ”点“。方法接受两个必填参数,第一个是经度(longitude),第二个是纬度(latitude),务必注意顺序。

# 参数

# longitude: number

经度

# latitude: number

纬度

# 返回值

# GeoPoint

# 索引

如存储地理位置信息的字段有被查询的需求,务必对字段建立地理位置索引

# 示例代码

db.collection('todos').add({
  data: {
    description: 'eat an apple',
    location: db.Geo.Point(113, 23)
  }
}).then(console.log).catch(console.error)

除了使用接口构造一个点外,也可以使用等价的 GeoJSON点 (Point) 的 JSON 表示,其格式如下:

{
  "type": "Point",
  "coordinates": [longitude, latitude] // 数字数组:[经度, 纬度]
}

示例代码

db.collection('todos').add({
  data: {
    description: 'eat an apple',
    location: {
      type: 'Point',
      coordinates: [113, 23]
    }
  }
}).then(console.log).catch(console.error)