Using elevation data

Use the Height Component node component to get either the elevation at a specific location, or the minimum or maximum elevation within the currently visible map area.

For example, use the Height Component when you want to:

Learn how to use the Height Component node component by completing a tutorial. See Tutorial: Using 3D terrain and satellite images.

../../_images/pois-positioned-preview.png

Using elevation data to control the position of the camera over 3D terrain

You can use the Height Component node component to get the elevation in a specific location, or the minimum or maximum elevation within the currently visible map area. The Height Component writes the elevation to a property to which you can bind the position of the camera. This way, you can make the camera follow the elevation of the terrain.

To use elevation data to control the position of the camera over 3D terrain:

  1. Create a Terrain 3D Renderer node that renders satellite imagery on 3D terrain. See Creating a Terrain 3D Renderer manually.

  2. Move the map to a mountainous area.

    For example:

    1. In the Node Tree, select the Screen node. In the Node Components > Triggers, create an On Attached trigger.

      ../../_images/node-tree-screen.png ../../_images/node-components-create-on-attached.png
    2. In the On Attached trigger, create a Set Property action and set:

      • Target Item to the Map View node that contains the Terrain 3D Renderer node

      • Target Property to World Center Latitude and Longitude

      • Value From to Fixed value

      • Fixed Value

        • X to 46.5221

        • Y to 10.46917

      This way, you set the center of the map in Italy, close to the Switzerland border. In the Preview, you cannot see the mountains because the camera is positioned below them.

      ../../_images/node-components-set-property-action.png
  3. In the Library > Property Types, create a float property type. For example, name the property type TerrainRendererHeight.

    ../../_images/create-property-type.png ../../_images/terrain-renderer-height-property.png
  4. In the Node Tree, select the Map View node. In the Node Components > Kanzi Maps, create a Height Component.

    Use the Height Component node component to get either the elevation at a specific location, or the minimum or maximum elevation within the currently visible map area.

    ../../_images/map-view-node-2.png ../../_images/create-height-component.png
  5. In the Height Component, set:

    • Source Type to:

      • Latitude and longitude to use a latitude-longitude coordinate provided by the property that you set with the Source Property Latitude-Longitude property

      • Maximum height to use the maximum height among the visible map tiles

      • Minimum height to use the minimum height among the visible map tiles

      For example, set it to Latitude and longitude, and set the Source Property Latitude-Longitude property to World Center Latitude and Longitude.

      This way, you set the Height Component to get the height value in the center of the map.

    • Target Property for Height to the float property type that you created

      For example, set it to TerrainRendererHeight.

      This way, you set the Height Component to write the height value to the TerrainRendererHeight property in the Map View node.

    ../../_images/node-components-height-component.png
  6. In the Properties, set the Height Map Layer Filter property to terrain3d.

    This way, you set the Map View node to get the height map from the terrain3d map layer. The height map provides for the Height Component the elevation data, which the Height Component writes to its target property.

    ../../_images/properties-map-view-height-map.png
  7. In the Node Tree, select the Camera node. In the Properties, add the Render Transformation property, and set the Rotation X property field to -25.

    ../../_images/camera-node.png ../../_images/properties-camera-transformation.png
  8. In the Properties, click + Add Binding and in the Binding Editor, set:

    • Property to Render Transformation

    • Property Field to TRANSLATION_Y

    • Expression to

      height = {@../Map View/TerrainRendererHeight}
      scale = {@../Map View/Maps.MapView.MapScale}
      height * scale + 6
      

    You bind the position of the camera on the y axis to the height of the terrain. You scale the height value by the Map Scale property of the Map View node. This way, you convert the height value from Mercator meters to Kanzi world space. You add a fixed offset of 5 units to make sure that the camera stays well above the surface of the terrain.

    ../../_images/binding-translation-y.png ../../_images/preview-camera-positioned.png
  9. (Optional) In the Node Tree, select the Map View node. In the Node Components > Animation, create a Property Target Interpolator and set the Interpolated Property Type to TerrainRendererHeight.

    The Property Target Interpolator interpolates the value of a property from its current value to the target value over time, emulating the behavior of a spring-damper system which never overshoots.

    You use the Property Target Interpolator to animate the changes in the camera height. This way, you make the camera follow the terrain smoothly.

    ../../_images/map-view-node-2.png ../../_images/create-property-target-interpolator.png ../../_images/interpolated-property-type.png ../../_images/property-target-interpolator.png

    Tip

    To pan the map in the Preview, click and drag the left mouse button.

See also

Using the Terrain 3D Renderer node

Tutorial: Using 3D terrain and satellite images