Tutorial: Create a feature stateset
Feature statesets define dynamic properties and values on specific features that support them. In this Tutorial, you'll:
- Create a stateset that defines boolean values and corresponding styles for the occupancy property.
- Change the
occupancy
property state of the desired unit.
Prerequisites
- Successful completion of Tutorial: Query datasets with WFS API.
- The
datasetId
obtained in the Check the dataset creation status section of the Use Creator to create indoor maps tutorial.
This tutorial uses the Postman application, but you can use a different API development environment.
Important
- This article uses the
us.atlas.microsoft.com
geographical URL. If your Creator service wasn't created in the United States, you must use a different geographical URL. For more information, see Access to Creator Services. - In the URL examples in this article you will need to replace:
{Azure-Maps-Primary-Subscription-key}
with your primary subscription key.{datasetId}
with thedatasetId
obtained in the Check the dataset creation status section of the Use Creator to create indoor maps tutorial
Create a feature stateset
To create a stateset:
In the Postman app, create a new HTTP Request and save it as POST Create Stateset.
Select the POST HTTP method.
Enter the following URL to the Stateset API. The request should look like the following URL:
https://us.atlas.microsoft.com/featurestatesets?api-version=2.0&datasetId={datasetId}&subscription-key={Your-Azure-Maps-Subscription-key}
Select the Headers tab.
In the KEY field, select
Content-Type
.In the VALUE field, select
application/json
.Select the Body tab.
Select raw and JSON.
Copy the following JSON styles, and then paste them in the Body window:
{ "styles":[ { "keyname":"occupied", "type":"boolean", "rules":[ { "true":"#FF0000", "false":"#00FF00" } ] } ] }
Select Send.
After the response returns successfully, copy the
statesetId
from the response body. In the next section, you'll use thestatesetId
to change theoccupancy
property state of the unit with featureid
"UNIT26".
Update a feature state
To update the occupied
state of the unit with feature id
"UNIT26":
In the Postman app, create a new HTTP Request and save it as PUT Set Stateset.
Select the PUT HTTP method.
Enter the following URL to the Feature Statesets API. The request should look like the following URL (replace
{statesetId
} with thestatesetId
obtained in Create a feature stateset):https://us.atlas.microsoft.com/featurestatesets/{statesetId}/featureStates/UNIT26?api-version=2.0&subscription-key={Your-Azure-Maps-Subscription-key}
Select the Headers tab.
In the KEY field, select
Content-Type
.In the VALUE field, select
application/json
.Select the Body tab.
Select raw and JSON.
Copy the following JSON style, and then paste it in the Body window:
{ "states": [ { "keyName": "occupied", "value": true, "eventTimestamp": "2020-11-14T17:10:20" } ] }
Note
The update will be saved only if the time posted stamp is after the time stamp of the previous request.
Select Send.
After the update completes, you'll receive a
200 OK
HTTP status code. If you implemented dynamic styling for an indoor map, the update displays at the specified time stamp in your rendered map.
Additional information
For information on how to retrieve the state of a feature using its feature id, see Feature State - List States.
For information on how to delete the stateset and its resources, see Feature State - Delete Stateset .
For information on using the Azure Maps Creator Feature State service to apply styles that are based on the dynamic properties of indoor map data features, see how to article Implement dynamic styling for Creator indoor maps.
For more information on the different Azure Maps Creator services discussed in this tutorial, see Creator Indoor Maps.
Feedback
Submit and view feedback for