Skip to content

Files

Latest commit

b35ccd7 · Apr 8, 2022

History

History
136 lines (92 loc) · 5.96 KB

tutorial-creator-feature-stateset.md

File metadata and controls

136 lines (92 loc) · 5.96 KB
title titleSuffix description author ms.author ms.date ms.topic ms.service services
Tutorial: Create a feature stateset
Microsoft Azure Maps
The third tutorial on Microsoft Azure Maps Creator. How to create a feature stateset.
stevemunk
v-munksteve
01/28/2022
tutorial
azure-maps
azure-maps

Tutorial: Create a feature stateset

Feature statesets define dynamic properties and values on specific features that support them. In this Tutorial, you'll:

[!div class="checklist"]

  • Create a stateset that defines boolean values and corresponding styles for the occupancy property.
  • Change the occupancy property state of the desired unit.

Prerequisites

This tutorial uses the Postman application, but you can use a different API development environment.

Important

This tutorial 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.

Create a feature stateset

To create a stateset:

  1. In the Postman app, create a new HTTP Request and save it as POST Create Stateset.

  2. Select the POST HTTP method.

  3. Enter the following URL to the Stateset API. The request should look like the following URL (replace {Azure-Maps-Primary-Subscription-key} with your primary subscription key, and {datasetId} with the datasetId obtained in the Check the dataset creation status section of the Use Creator to create indoor maps tutorial):

    https://us.atlas.microsoft.com/featurestatesets?api-version=2.0&datasetId={datasetId}&subscription-key={Your-Azure-Maps-Primary-Subscription-key}
  4. Select the Headers tab.

  5. In the KEY field, select Content-Type.

  6. In the VALUE field, select application/json.

    :::image type="content" source="./media/tutorial-creator-indoor-maps/stateset-header.png"alt-text="A screenshot of Postman showing the Header tab of the POST request that shows the Content Type Key with a value of application forward slash json.":::

  7. Select the Body tab.

  8. Select raw and JSON.

  9. Copy the following JSON styles, and then paste them in the Body window:

    {
       "styles":[
          {
             "keyname":"occupied",
             "type":"boolean",
             "rules":[
                {
                   "true":"#FF0000",
                   "false":"#00FF00"
                }
             ]
          }
       ]
    }
  10. Select Send.

  11. After the response returns successfully, copy the statesetId from the response body. In the next section, you'll use the statesetId to change the occupancy property state of the unit with feature id "UNIT26".

    :::image type="content" source="./media/tutorial-creator-indoor-maps/response-stateset-id.png"alt-text="A screenshot of Postman showing the resource Stateset ID value in the responses body.":::

Update a feature state

To update the occupied state of the unit with feature id "UNIT26":

  1. In the Postman app, create a new HTTP Request and save it as PUT Set Stateset.

  2. Select the PUT HTTP method.

  3. Enter the following URL to the Feature Statesets API. The request should look like the following URL (replace {Azure-Maps-Primary-Subscription-key} with your primary subscription key, and {statesetId} with the statesetId obtained in Create a feature stateset):

    https://us.atlas.microsoft.com/featurestatesets/{statesetId}/featureStates/UNIT26?api-version=2.0&subscription-key={Your-Azure-Maps-Primary-Subscription-key}
  4. Select the Headers tab.

  5. In the KEY field, select Content-Type.

  6. In the VALUE field, select application/json.

    :::image type="content" source="./media/tutorial-creator-indoor-maps/stateset-header.png"alt-text="Header tab information for stateset creation.":::

  7. Select the Body tab.

  8. Select raw and JSON.

  9. 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.

  10. Select Send.

  11. 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