Data - API Client JS

MapTiler API Client JS data functions allow you to retrieve your data in GeoJSON format.

MapTiler allow users to upload and create data; either manually with a user interface, or by uploading a GPX, GeoJSON, KML, or shp file. Each dataset is assigned a unique ID so that it can be accessed programmatically later to retrieve a GeoJSON equivalent.

Provides a way to retrieve user data in GeoJSON format. Since the result is a GeoJSON, it can easily be added to a map with .addSource() and .addLayer().

// in an async function, or as a 'thenable':
const result = await maptilerClient.data.get('my-dataset-unique-id');

Parameters

dataId Identifier of the data. Unique ID is associated to the MapTiler Dataset.
options.apiKey Custom MapTiler API key to use instead of the one in global config.

Response

Returns a GeoJSON object

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -11.45962733,
              43.0561248
            ],
            [
              4.47204969,
              43.26001347
            ],
            [
              -8.94409938,
              36.17600093
            ],
            [
              -16.77018634,
              37.73931498
            ],
            [
              -11.45962733,
              43.0561248
            ]
          ]
        ]
      },
      "id": "ca41379b-f969-49a8-8c8f-3edd7d05fb20",
      "properties": {
        "name": "Iberia",
        "type": "1"
      }
    }
  ]
}

Read more about data on our official API documentation.