Using the Prefab Object Renderer node

Use the Prefab Object Renderer node to instantiate a prefab on a map at given coordinates. For example, you can render a navigation marker, or visualize route waypoints or geocoding results.

The Prefab Object Renderer instantiates a prefab on a map at either:

  • Given WGS84 latitude-longitude coordinates.

  • In target projection using integer coordinates measured at 2 centimeter resolution, that is, in units of 2 cm.

You can use the Coordinate Renderer similarly to the Prefab Object Renderer. Their difference is that the Coordinate Renderer moves its child nodes to a specific location on the map, while the Prefab Object Renderer instantiates a prefab. See Using the Coordinate Renderer node.

To use the Prefab Object Renderer node to render a waypoint marker:

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

    For example, create a Prefab Object Renderer node in a Map View node where you want to render a waypoint marker for a route that you render using the Route Renderer node. See Creating a Route Renderer manually.

    ../../_images/node-tree-create-prefab-object-renderer.png
  2. In the Prefabs, create a prefab that you use to mark the waypoint.

    For example:

    1. Create an Empty Node 3D prefab that contains a Box node and a Sphere node.

      ../../_images/prefabs-waypoint-marker.png
    2. Set the material and size of the Box and Sphere nodes. Position them along the y axis so that the Sphere is centered at the top of the Box.

      ../../_images/properties-box.png ../../_images/properties-sphere.png
  3. In the Data Sources window, click Create Data Source and set the Data Source Type to Kanzi.Maps.NavigationDataSource.

    You use this Navigation Data Source to provide navigation data to the Prefab Object Renderer node.

    ../../_images/create-data-source.png ../../_images/create-navigation-data-source.png
  4. In the Node Tree, select the Prefab Object Renderer node. In the Properties, add and set:

    • Data Context > Data Context property to the Navigation Data Source that you created in the previous step

    • Prefab to the prefab that you want to use to visualize waypoints.

    Make sure that the Scaling property is set to Map Scale. This way, the Prefab Object Renderer scales the prefab relative to the zoom level of the map.

    ../../_images/node-tree-prefab-object-renderer.png ../../_images/properties-prefab-object-renderer.png
  5. In the Properties, click + Add Binding and in the Binding Editor, set:

    • Property to Prefab Object Renderer > Lat/lon Coordinates

    • Property Field to VECTOR_X

    • Expression to

      {DataContext.LastWaypoint.Lat}
      

    This way, you set the WGS84 latitude coordinate of the Prefab Object Renderer node to the value of the LastWaypoint > Lat data object in the Navigation Data Source.

    ../../_images/binding-last-waypoint-lat.png ../../_images/data-sources-last-waypoint-lat.png
  6. Repeat the previous step, but in the Binding Editor, set:

    • Property Field to VECTOR_Y

    • Expression to

      {DataContext.LastWaypoint.Long}
      

    This way, you set the WGS84 longitude coordinate of the Prefab Object Renderer node to the value of the LastWaypoint > Long data object in the Navigation Data Source.

    ../../_images/binding-last-waypoint-long.png

The Prefab Object Renderer node instantiates the waypoint marker prefab at the end of the route.

To visualize the start point of the route, create another Prefab Object Renderer node where you bind the WGS84 latitude-longitude coordinates to the FirstWaypoint > Lat and Long data objects.

../../_images/preview-waypoint-marker.png

See also

Renderer nodes

Using the Coordinate Renderer node

Using the Route Renderer node