Using the Prefab Feature Renderer node

Use the Prefab Feature Renderer node to instantiate a prefab in place of all instances of a specific map feature, such as place of interest or street label.

The Prefab Feature Renderer can render 2D point or 2D line string feature geometry.

Kanzi Maps sources the map features from a data source that provides a list data object named features, where each item contains either:

  • latitude and longitude data objects.

  • geometry data object, where geometry is of type DataObjectGeometry. This is available only through the Kanzi Maps plugin.

The Prefab Feature Renderer typically uses the Tile Data Source. See Using the Tile Data Source.

Learn how to use the Prefab Feature Renderer node by completing a tutorial. See Tutorial: Points of interest and labels.

../../_images/adding-pois-completed2.png

Creating a Prefab Feature Renderer using the Palette

This section explains how to use the Kanzi Maps Palette to quickly create and set up a Prefab Feature Renderer that renders the labels of major roads, places of interest, cities, or countries.

To create a Prefab Feature Renderer using the Palette:

  1. In the Node Tree, select the Map View node where you want to render prefab features.

    ../../_images/map-view-node4.png
  2. In the Kanzi Studio main menu, select Kanzi Maps > Palette.

    ../../_images/kanzi-maps-palette-menu2.png
  3. When Kanzi Studio asks whether you want to import assets, click Yes.

    ../../_images/import-assets1.png
  4. In the Kanzi Maps Palette, select the type of prefab features that you want to render and click Create.

    You can use the Palette to render these types of prefab features:

    • Major Road labels

    • POI labels

    • City labels

    • Country labels

    For example, select City labels and click Create.

    ../../_images/palette-create-city-labels.png
  5. In the Confirm modifications dialog, click Apply Modifications to let Kanzi Studio modify your project as needed to render the content that you selected.

Kanzi Maps creates in the Map View node a Prefab Feature Renderer node named City Labels, which gets the city labels from a Tile Data Source. The KanziMaps_CityLabel prefab defines the look of the labels.

../../_images/properties-city-labels.png

In the Map Control, decrease the zoom level to see more city labels.

../../_images/preview-city-labels.png

Creating a Prefab Feature Renderer manually

To create a Prefab Feature Renderer manually:

  1. In the Node Tree, press Alt and right-click a Map View node and select Prefab Feature Renderer.

    For example, create a Prefab Feature Renderer node that you use to render the labels of places of interest, and name it Points of Interest.

    ../../_images/node-tree-create-prefab-feature-renderer1.png
  2. Create and configure the data source:

    1. In the Data Sources window, click Create Data Source and set the Data Source Type to Kanzi.Maps.TileDataSource.

      This way, you create a Tile Data Source that exposes all map features in the currently visible map area as a flat list.

      ../../_images/create-data-source3.png ../../_images/pois-data-source2.png
    2. In the Node Tree, select the Prefab Feature Renderer node. In the Properties, add and set:

      • Data Context > Data Context to the Tile Data Source that you created.

        This way, you enable the Prefab Feature Renderer node to access the map features from the Tile Data Source.

        Tip

        To set the Data Context property, you can drag a data source from the Data Sources window to the Effective Data Context property in the Properties.

      • (Optional) Scaling to Object scale

        This way, the size of the items stays the same when the zoom level of the map changes.

      ../../_images/points-of-interest-properties2.png
    3. Select Kanzi Maps > Renderer Editor.

      Use the Renderer Editor to set layer and metadata filters that define the map features that a Renderer node renders.

      ../../_images/kanzi-maps-renderer-editor-menu3.png

      Make sure that the Prefab Feature Renderer node is selected in the Node Tree.

    4. In the Renderer Editor, set the Layer to the name of the layer from which you want the Tile Data Source to get map features.

      For example, to get the icons and labels for points of interest, set it to poi_label.

      ../../_images/renderer-editor-poi-labels1.png
    5. In the Data Sources window, click reload-data-source next to the POIs data source to create data objects from that data source.

      ../../_images/pois-items1.png

      Tip

      To view the configuration of a Tile Data Source, in the Data Sources next to that data source click configure-data-source.

      ../../_images/pois-configure-data-source1.png ../../_images/pois-data-source-properties1.png
  3. Create and configure the prefab template:

    1. In the Prefabs, create a prefab that defines the look of each instance of a map feature that the Prefab Feature Renderer node renders.

      For example:

      1. Create an Empty Node 3D node named POI.

      2. In the POI prefab, create a Text Block 3D node named Name.

      3. Select the Name node.

      4. From the Data Sources > Tile Data Source, drag the features > Item > name_en data object to the Properties and drop it on the Text property.

        You set the Name node to show the English name of a point of interest that is set in the name_en data object. When you drop a data object on a property, Kanzi Studio binds the value of that property type to the value of the data object.

      ../../_images/drag-name-data-object1.gif
    2. In the Node Tree, select the Prefab Feature Renderer node. In the Properties, set the Prefab property to the prefab template that you created.

      In the Preview, you can see an instance of the prefab at every instance of the map feature that you configured the Tile Data Source to get.

      ../../_images/prefab-poi1.png ../../_images/preview-poi-labels-initial.png
  4. To filter the map features that the Prefab Feature Renderer node renders, either:

    • In the Properties, next to the Data Context property, click configure-data-source and set the Metadata Filter.

      For example, set it to

      filterrank <= 2 && sizerank <= 14
      

      You use the filterrank field to show only prominent labels and the sizerank field to filter features based on their size relative to the current zoom level.

      ../../_images/properties-tile-data-source-metadata-filter.png
    • In the Renderer Editor, define the metadata filter. See Using the Renderer Editor.

      ../../_images/poi-metadata-filter1.png
    ../../_images/preview-poi-labels-filtered.png

See also

Using the Tile Data Source

Using the Palette

Using the Renderer Editor