Click here to see your recently viewed pages and most viewed pages.
Hide
Google Maps Engine API (Deprecated)

Creating features

New features can be appended to a table using a POST request to the /tables/tableId/features/batchInsert endpoint.

Limits

A single request can create:

  • Up to 50 features.
  • A combined total of 10 000 vertices.

Feature limits are documented in the Supported data formats and limits article of the Google Maps Engine help center. Note that free and paid accounts have different limits.

Request

The two polygons illustrated below are inserted with the following request.

Figure 1: Simple polygon

Figure 2: Complex polygon

POST https://www.googleapis.com/mapsengine/v1/tables/tableId/features/batchInsert
Authorization: Bearer token

{
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [[1.0, 3.0], [1.0, 1.0], [4.0, 1.0], [4.0, 4.0], [1.0, 3.0]]
        ]
      },
      "properties": {
        "gx_id": "100",
        "name": "Simple polygon",
        "figure": "1"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [[1,4], [1,1], [4,1], [4,4], [1,4]],
          [[2,3], [2,2], [3,2], [3,3], [2,3]]
        ]
      },
      "properties": {
        "gx_id": "200",
        "name": "Complex polygon",
        "figure": "2"
      }
    }
  ]
}

Request body

The body of the request must contain:

  • A features array. From 1 to 50 features can be appended to a table in a single request. A maximum of 2000 vertices can be passed with a single request.

Each feature within the array must contain:

  • A type whose value is Feature.
  • A single geometry field. The geometry may be explicitly null. If not null, it must contain:

    • A type field. Supported types are Point, LineString, Polygon, and GeometryCollection. Please refer to the Geometry objects section of the Reference documentation for details.
    • A coordinates field, containing one or more positions. A position is an array containing a single longitude, a single latitude, and optionally a single altitude value, in that order. Polygons must be specified in a counter-clockwise direction, with the first and last positions the same. For polygons with multiple rings, the outside ring must be specified first.
  • A properties nested object, with one or more entries which conform to the target table's schema. It must contain:

    • A primary key whose value is unique within the table. Refer to the table's schema to find the primary key column; it's specified as the value of a primaryKey field. See Primary Keys for more information and for advice on creating unique identifiers. In the example above, the primary key column is gx_id.

    The properties object may contain:

    • A gx_location field with an address string, to be automatically geocoded by the Maps Engine service. See the Geocoding page for details.
    • Any other key-value pairs that conform to the target table's schema.

    For any field in the properties object, integer values must be enclosed in double quotes (eg. "20").
    Float values must not be enclosed in quotes (eg. 1.983).

Response

A successful create request returns HTTP status code 204 (No content). No response body is returned.

Errors

Some common errors are explained below:

  • If gx_id is not unique within the table, duplicate is returned.
  • If geometry is omitted, the API returns a required error.
  • If type is not Feature, an InvalidValue error is returned.
  • No schema may be provided; InvalidValue is returned. The request's tableId identifies an existing table, which defines the schema.
  • If the structure of the supplied coordinates field does not match the geometry's type, InvalidValue is returned.
  • Each property must exist as a key in the table's schema, and the associated column must be capable of storing the given value. Otherwise, InvalidValue is returned