Geo.MultiLineString(lineStrings: GeoLineString[]): GeoMultiLineString

View Markdown

Last edited on 2026-07-04

Supported on: Mini Program 2.6.3, Cloud Functions

Constructs a collection of geographic "lines." A line collection consists of multiple lines.

Parameters

lineStrings: GeoLineString[]

Array of "lines"

Return Value

GeoMultiLineString

Index

If there is a need to query fields that store geographic location information, you must create a geographic index for those fields.

Sample Code

const { LineString, MultiLineString, Point } = db.Geo
db.collection('todos').add({
  data: {
    description: 'eat an apple',
    location: MultiLineString([
      LineString([ Point(0, 0), Point(30, 20), Point(20, 30), Point(0, 0) ]),
      LineString([ Point(10, 10), Point(16, 14), Point(14, 16), Point(10, 10) ])
    ])
  }
}).then(console.log).catch(console.error)

In addition to constructing a MultiLineString using the API, you can also use the equivalent JSON representation of a MultiLineString in GeoJSON, which is formatted as follows:

{
  "type": "MultiLineString",
  "coordinates": [
    [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ],
    [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ],
    ...
    [ [lng, lat], [lng, lat], [lng, lat], ..., [lng, lat] ]
  ]
}

Sample Code

db.collection('todos').add({
  data: {
    description: 'eat an apple',
    location: {
      type: 'MultiLineString',
      coordinates: [
        [ [0, 0], [3, 3] ],
        [ [5, 10], [20, 30] ]
      ]
    }
  }
}).then(console.log).catch(console.error)