Using the XML Data Source

The XML Data Source gets data from an XML file.

Creating an XML Data Source

To create an XML Data Source:

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

    ../../_images/create-data-source2.png ../../_images/create-xml-data-source.png
  2. In the Data Sources window next to the XML Data Source that you created, click configure-data-source and set the XML File property to the XML file from which you want to get the data.

    ../../_images/data-sources-xml-file.png

Rendering points of interest from an XML file

To render points of interest from an XML file:

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

    ../../_images/node-tree-create-prefab-feature-renderer.png
  2. In the Data Sources window, click Create Data Source and set the Data Source Type to Kanzi.Maps.XMLDataSource.

    ../../_images/create-data-source2.png ../../_images/create-xml-data-source.png
  3. In the Data Sources window next to the XML Data Source that you created, click configure-data-source and set the XML File property to the XML file from which you want to get the data.

    For example, save this text in an XML file:

    <features type="list">
        <items>
            <feature>
                <latitude type="float">40.70042247927178</latitude>
                <longitude type="float">-74.01351928710938</longitude>
                <maki type="string">cafe</maki>
                <name_en type="string">cafe example</name_en>
            </feature>
            <feature>
                <latitude type="float">40.702727</latitude>
                <longitude type="float">-74.011819</longitude>
                <maki type="string">fuel</maki>
                <name_en type="string">gas station example</name_en>
            </feature>
        </items>
    </features>
    
    ../../_images/data-sources-xml-file.png
  4. In the Node Tree, select the Prefab Feature Renderer node. In the Properties, add and set:

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

      This way, you enable the Prefab Feature Renderer node to access the map features from the XML 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.

    • Scaling to Object scale

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

    ../../_images/node-tree-prefab-feature-renderer.png ../../_images/properties-prefab-feature-renderer.png
  5. In the Prefabs, create a prefab that you use to define the look of each point of interest 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.

      ../../_images/prefabs-name.png
    3. Select the Name node. In the Properties, click + Add Binding and in the Binding Editor, set:

      • Property to Text

      • Expression to

        {DataContext.name_en}
        

      You set the Name node to show the English name of a point of interest that is set in the name_en data object.

      ../../_images/binding-editor-name-text.png
  6. In the Node Tree, select the Prefab Feature Renderer node. In the Properties, set the Prefab property to the prefab that you created in the previous step.

    ../../_images/node-tree-prefab-feature-renderer.png ../../_images/properties-prefab-feature-renderer-prefab.png

Example

To learn how to use the XML Data Source, see the 3D terrain example, which uses the XML Data Source to set points of interest based on the data in an XML file. You can find the Kanzi Studio project of the example at <KanziWorkspace>/Engine/plugins/maps/examples/maps_terrain3d/Tool_project/MapsTerrain3D.kzproj. See Examples.

In the PointOfInterestFromXMLRender Prefab Feature Renderer node, the Data Context property is set to the Point-of-interest-from-xml XML Data Source. The Point-of-interest-from-xml XML Data Source is configured to used the <KanziWorkspace>/Engine/plugins/maps/examples/maps_terrain3d/Application/bin/POI_points.xml file:

<features type="list">
    <items>
        <feature>
            <latitude type="float">37.794349</latitude>
            <longitude type="float">-122.468590</longitude>
            <maki type="string">golf</maki>
            <name_en type="string">golf sample from xml data</name_en>
        </feature>
        <feature>
            <latitude type="float">37.793383</latitude>
            <longitude type="float">-122.466401</longitude>
            <maki type="string">cafe</maki>
            <name_en type="string">cafe sample from xml data</name_en>
        </feature>
        <feature>
            <latitude type="float">37.785843</latitude>
            <longitude type="float">-122.458823</longitude>
            <maki type="string">fuel</maki>
            <name_en type="string">gas station sample from xml data</name_en>
        </feature>
    </items>
</features>

See also

Using the Geocoding Data Source

Using the Navigation Data Source

Using the Route Data Source

Using the Tile Data Source

Examples