Librerie client dell'API Maps Datasets

Questa pagina mostra come iniziare a utilizzare le librerie client per l'API Maps Datasets.

Per ulteriori informazioni sulle librerie client, consulta la pagina Spiegazione delle librerie client.

installa la libreria client

Node.js

Per ulteriori informazioni, consulta la sezione Configurare un ambiente di sviluppo Node.js.

npm install @googlemaps/maps-platform-datasets

Python

Per ulteriori informazioni, consulta la sezione Configurazione di un ambiente di sviluppo Python.

pip install --upgrade google-maps-mapsplatformdatasets

Configura l'autenticazione

Quando usi le librerie client, per l'autenticazione vengono usate le credenziali predefinite dell'applicazione (ADC). Per informazioni sulla configurazione di ADC, consulta Fornire le credenziali per le credenziali predefinite dell'applicazione. Per informazioni sull'utilizzo di ADC con le librerie client, consulta Autenticazione tramite librerie client.

Utilizzare la libreria client

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)

Risorse aggiuntive