The Map Management API lets you manage your cloud-based maps styling resources using RESTful APIs.
Summary of steps
- Use the Cloud console to create a map ID (limited to JavaScript vector-based maps).
- Use the Cloud console to create a map style. A map style is used as the link between a map ID and a dataset.
- Use either the Cloud Console or the Maps Datasets API to create a dataset.
- Use the Map Management API to associate the dataset with the style ID.
- Use the map ID in an application (JS, iOS, or Android) and use the data-driven styling API to style dataset features.
Types
DatasetStyleAssociation
Type: Object/Proto
Encapsulates the relationship between an existing dataset and an existing Client Style.
message DatasetStyleAssociation {
option (google.api.resource) = {
type: "mapstyling.googleapis.com/DatasetStyleAssociation"
pattern: "projects/{project}/datasets/{dataset}/clientStyles/{client_style}"
plural: "datasetStyleAssociations",
singular: "datasetStyleAssociation"
};
// Resource name.
// projects/{project}/datasets/{dataset}/clientStyles/{client_style}
string name = 1;
// The resource name of the style.
// projects/{project}/clientStyles/{client_style}
string client_style = 2;
Methods
CreateDatasetStyleAssociation
rpc CreateDatasetStyleAssociation(CreateDatasetStyleAssociationRequest)
returns (DatasetStyleAssociation) {
option (google.api.http) = {
post: "/v1/{parent=projects/*/datasets/*}"
body: "dataset_style_association"
};
option (google.api.method_signature) = parent,dataset_style_association";
}
ListDatasetStyleAssociations
rpc ListDatasetStyleAssociations(ListDatasetStyleAssociationsRequest)
returns (ListDatasetStyleAssociationsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/datasets/*}"
};
option (google.api.method_signature) = "parent";
}
DeleteDatasetStyleAssociation
rpc DeleteDatasetStyleAssociation(DeleteDatasetStyleAssociationRequest)
returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v1/{name=projects/*/datasets/*/clientStyles/*}:delete"
body: "*"
};
option (google.api.method_signature) = "name";
}
Example C++ calls
Sample Call to Create Endpoint
<pre>curl --http2 -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer <Token>' https://mapmanagement.googleapis.com/v1/projects/<Project_Number>/datasets/{dataset_id} -d '{name: "projects/{project_number}/datasets/{dataset_id}/clientStyles/{style_id}", client_style: "projects/{project_number}/clientStyles/{style_id}" }'</pre>
Sample Call to List Endpoint
<pre>curl --http2 -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer <Token>' https://mapmanagement.googleapis.com/v1/projects/<Project_Number>/datasets/-</pre>
Sample Call to List Associated Maps
<pre>curl --http2 -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer <Token>' https://mapmanagement.googleapis.com/v1/projects/<Project_Number>/datasets/<dataset-id>/clientStyles/<style_id>:listAssociatedMaps</pre>
Sample Call to Delete Endpoint
<pre>curl --http2 -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer <Token>' https://mapmanagement.googleapis.com/v1/projects/<Project_Number>/datasets/<dataset_id>/clientStyles/<style_id>:delete -d '{"map_ids": ["map-id-1", "map-id-2"]}'</pre>
Errors
PERMISSION_DENIED : These errors always detail what resource access is denied. For example, when the API is not enabled for the supplied project.
ALREADY_EXISTS: Triggered by a Create call when the DatasetStyleAssociation already exists.
NOT_FOUND: Triggered by any of the above methods when an attempt is made to access a resource that does not exist, such as a Style, Dataset, or Project.
INVALID_ARGUMENT: Request is malformed.