Maps Datasets API 客户端库

本页介绍了如何开始使用 Maps Datasets API 的客户端库。

如需详细了解客户端库,请参阅客户端库说明

安装客户端库

Node.js

如需了解详情,请参阅设置 Node.js 开发环境

npm install @googlemaps/maps-platform-datasets

Python

如需了解详情,请参阅设置 Python 开发环境

pip install --upgrade google-maps-mapsplatformdatasets

设置身份验证

使用客户端库时,您可以使用应用默认凭据 (ADC) 进行身份验证。如需了解如何设置 ADC,请参阅为应用默认凭据提供凭据。如需了解如何将 ADC 与客户端库搭配使用,请参阅使用客户端库进行身份验证

使用客户端库

Node.js

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. Parent project that will own the dataset.
 *  Format: projects/{project}
 */
// const parent = 'abc123'
/**
 *  Required. The dataset version to create.
 */
// const dataset = {}

// Imports the Mapsplatformdatasets library
const {MapsPlatformDatasetsClient} = require('@googlemaps/maps-platform-datasets').v1;

// Instantiates a client
const mapsplatformdatasetsClient = new MapsPlatformDatasetsClient();

async function callCreateDataset() {
  // Construct request
  const request = {
    parent,
    dataset,
  };

  // Run request
  const response = await mapsplatformdatasetsClient.createDataset(request);
  console.log(response);
}

callCreateDataset();

Python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.maps import mapsplatformdatasets_v1


def sample_create_dataset():
    # Create a client
    client = mapsplatformdatasets_v1.MapsPlatformDatasetsClient()

    # Initialize request argument(s)
    request = mapsplatformdatasets_v1.CreateDatasetRequest(
        parent="parent_value",
    )

    # Make the request
    response = client.create_dataset(request=request)

    # Handle the response
    print(response)

其他资源