Skip to content
GuidesPlaygroundDashboard

Match GPS coordinates to the road network

client.MapMatch.Match(ctx, body) (*MapMatchResult, error)
POST/api/v1/map-match

Match GPS coordinates to the road network

ParametersExpand Collapse
body MapMatchMatchParams
MapMatchRequest param.Field[MapMatchRequest]

GPS trace to match against the road network

ReturnsExpand Collapse
type MapMatchResult struct{…}

Map matching result with snapped geometry

Coordinates GeoJsonGeometryCoordinatesUnion

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
type GeoJsonGeometryCoordinatesArray []float64
type GeoJsonGeometryCoordinatesArray [][]float64
type GeoJsonGeometryCoordinatesArray [][][]float64
type GeoJsonGeometryCoordinatesArray [][][][]float64
Type GeoJsonGeometryType
One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties MapMatchResultProperties
Confidence float64optional

Match confidence score

Distance float64optional

Total matched distance in meters

Duration float64optional

Estimated duration in seconds

Type MapMatchResultType
Legs []map[string, unknown]optional

Matched route legs between consecutive trace points

Match GPS coordinates to the road network

package main

import (
  "context"
  "fmt"

  "github.com/plazafyi/plaza-go"
  "github.com/plazafyi/plaza-go/option"
)

func main() {
  client := githubcomplazafyiplazago.NewClient(
    option.WithAPIKey("My API Key"),
  )
  mapMatchResult, err := client.MapMatch.Match(context.TODO(), githubcomplazafyiplazago.MapMatchMatchParams{
    MapMatchRequest: githubcomplazafyiplazago.MapMatchRequestParam{
      Trace: githubcomplazafyiplazago.F(githubcomplazafyiplazago.GeoJsonGeometryParam{
        Coordinates: githubcomplazafyiplazago.F[githubcomplazafyiplazago.GeoJsonGeometryCoordinatesUnionParam](githubcomplazafyiplazago.GeoJsonGeometryCoordinatesArrayParam([]float64{0.000000})),
        Type: githubcomplazafyiplazago.F(githubcomplazafyiplazago.GeoJsonGeometryTypePoint),
      }),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", mapMatchResult.Geometry)
}
Returns Examples