How to publish data to an interactive map layer
To publish data to an interactive map layer using the interactive REST API:
- Obtain an authorization token to use with your HTTP requests. For more information, see the Identity and Access Management Guide.
- Use the API Lookup service to get the base URL for the
interactiveAPI for the catalog you want to write to. For more information on how to use the API Lookup service, see the API Lookup Developer Guide. - Send your data to the layer using the POST or PUT requests of the
interactiveAPI.
Add features
There are two methods to add features to your layer. However, note the critical difference with how each method handles existing data in the layer:
- Use
POSTto create new features or patch existing features. - Use
PUTto create new features or replace existing features.
POST method
POST methodThis method allows you to create, update, and delete features, while also enabling users to combine multiple operations into a single request.
POST /<Base path for the interactive API from the API Lookup Service>/layers/<Layer ID>/featuresThe API request body supports two Content types: FeatureCollection, which is the default type, and FeatureModificationList.
FeatureCollection
Request:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"featureclass": "River"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
...
], ... [
...
]
]
}
}
]
}Response:
{
"features": [
{
"geometry": {
"type": "LineString",
"coordinates": [
[
...
], ... [
...
]
]
},
"id": "NTvvEciZlE",
"type": "Feature",
"properties": {
"featureclass": "River",
"@ns:com:here:xyz": {
"createdAt": 1528461230706,
"updatedAt": 1528461230706
}
},
"bbox": [
44.41260826914623,
31.5295270854107,
45.66944420664623,
32.563421942181535
]
}
],
"type": "FeatureCollection"
}FeatureModificationList
The FeatureModificationList type allows you to set the behavioral properties to either onFeatureNotExists or onFeatureExists.
onFeatureNotExists
If no feature with the provided ID exists or if the provided feature contains no ID, then one of the following actions can be taken:
create- A new object is created. This is the default action.retain- No action is executed, allowing the execution of the batch operation to continue.error- If no object with the provided ID exists, an error is raised, which results in the whole batch operation being canceled.
onFeatureExists
If a feature with the provided ID exists, then one of the following actions can be taken:
patch- The feature object is handled as a partial update object which may contain only the properties to be modified. Properties that do not exist in the object are inserted, and the values for all existing properties are updated, unless the value of the property is set to null, which results in the property being removed from the object. This is the default action.replace- If an object with the provided ID exists, it will be replaced with the provided feature object.merge- The provided feature object is handled as a full object version and not a partial update.delete- The feature with the provided ID is deleted.retain- The current state of the feature is retained and included in the response.error- Raises an error if the object already exists.
Request:
{
"type": "FeatureModificationList",
"modifications": [
{
"type": "FeatureModification",
"onFeatureExists": "update",
"onFeatureNotExists": "create",
"featureData": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "NTvvEciZlE",
"properties": {
"featureclass": "Roads"
}
}
]
}
},
{
"type": "FeatureModification",
"onFeatureExists": "delete",
"onFeatureNotExists": "retain",
"featureIds": [
"<id2>",
"<id3>"
]
}
]
}Response:
{
"features": [
{
"geometry": {
"type": "LineString",
"coordinates": [
[
...
], ... [
...
]
]
},
"id": "NTvvEciZlE",
"type": "Feature",
"properties": {
"featureclass": "Roads",
"@ns:com:here:xyz": {
"createdAt": 1528461230706,
"updatedAt": 1528461230706
}
},
"bbox": [
44.41260826914623,
31.5295270854107,
45.66944420664623,
32.563421942181535
]
}
],
"type": "FeatureCollection"
}Use PUT
You receive the same response using the following PUT request:
PUT /<Base path for the interactive API from the API Lookup Service>/layers/<Layer ID>/featuresRequest:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"featureclass": "River"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
...
], ... [
...
]
]
}
}
]
}Response:
{
"features": [
{
"geometry": {
"type": "LineString",
"coordinates": [
[
...
], ... [
...
]
]
},
"id": "NTvvEciZlE",
"type": "Feature",
"properties": {
"featureclass": "River",
"@ns:com:here:xyz": {
"createdAt": 1528461230706,
"updatedAt": 1528461230706
}
},
"bbox": [
44.41260826914623,
31.5295270854107,
45.66944420664623,
32.563421942181535
]
}
],
"type": "FeatureCollection"
}Note
When using a version enabled interactive map layer, publishing data using any of the above methods will automatically increment the version number of a layer.
Updated last month