Play KML tour

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Play tours in KML files.

Image of play KML tour

Use case

KML, the file format used by Google Earth, supports creating tours, which can control the viewpoint of the scene, hide and show content, and play audio. Tours allow you to easily share tours of geographic locations, which can be augmented with rich multimedia. Runtime allows you to consume these tours using a simple API.

How to use the sample

The sample will load the KMZ file from ArcGIS Online. When a tour is found, the Play button will be enabled. Use Play and Pause to control the tour. When you're ready to show the tour, use the reset button to return the tour to the unplayed state.

This sample is graphics intensive and includes audio. Performance may be poor on emulated and remote devices. Run the sample on a physical device for best performance.

How it works

  1. Load the KML file and add it to a layer.
  2. Create the KML tour controller. Wire up the buttons to the Play, Pause, and Reset methods.
  3. Explore the tree of KML content to find the first KML tour. Once a tour is found, provide it to the KML tour controller.
  4. Enable the buttons to allow the user to play, pause, and reset the tour.

Relevant API

  • KmlTour
  • KmlTour.PropertyChanged
  • KmlTour.TourStatus
  • KmlTourController
  • KmlTourController.Pause()
  • KmlTourController.Play()
  • KmlTourController.Reset()
  • KmlTourController.Tour

Offline data

Data will be downloaded by the sample viewer automatically.

About the data

This sample uses a custom tour created by a member of the ArcGIS Runtime API samples team. When you play the tour, you'll see a narrated journey through some of Esri's offices.

Additional information

See Touring in KML in Keyhole Markup Language for more information.

Tags

animation, interactive, KML, narration, pause, play, story, tour

Sample Code

PlayKmlTours.xamlPlayKmlTours.xamlPlayKmlTours.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.PlayKmlTours.PlayKmlTours"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:resources="clr-namespace:Forms.Resources;assembly=ArcGISRuntime">
    <RelativeLayout>
        <esriUI:SceneView x:Name="MySceneView"
                          BindingContext="{x:Reference Name=ResponsiveFormContainer}"
                          Style="{StaticResource SceneWithFormStyle}" />
        <resources:ResponsiveFormContainer x:Name="ResponsiveFormContainer">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label Grid.Row="0"
                       Grid.Column="0"
                       Grid.ColumnSpan="3"
                       Margin="0,0,0,5"
                       Text="Use the buttons to control the tour. Contains audio. 🎧" />
                <Button x:Name="PlayButton"
                        Grid.Row="1"
                        Grid.Column="0"
                        Clicked="Play_Clicked"
                        IsEnabled="False"
                        Text="Play" />
                <Button x:Name="PauseButton"
                        Grid.Row="1"
                        Grid.Column="1"
                        Margin="5,0,5,0"
                        Clicked="Pause_Clicked"
                        IsEnabled="False"
                        Text="Pause" />
                <Button x:Name="ResetButton"
                        Grid.Row="1"
                        Grid.Column="2"
                        Clicked="Reset_Clicked"
                        IsEnabled="False"
                        Text="Reset" />
                <ActivityIndicator x:Name="LoadingStatusBar"
                                   Grid.Row="2"
                                   Grid.Column="0"
                                   Grid.ColumnSpan="3"
                                   Margin="0,5,0,0"
                                   IsEnabled="True"
                                   IsRunning="True" />
            </Grid>
        </resources:ResponsiveFormContainer>
    </RelativeLayout>
</ContentPage>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.