Search code examples
kmlgoogle-earth

google earth icon follow track in fixed orientation


I've created a track in google earth and included an icon to follow the track when it's played. The icon is a photo. Currently as the icon follows the track it re-orientates with the track direction. I want to make the icon follow the path of the track but maintain a fixed orientation. For example the photo used as the icon should follow the track but always stay the correct orientation on the screen. Is this possible?


Solution

  • You can use the <gx:angles> tag to specify the angle of the icon image.

    That tag lets you define 3 angles (heading, tilt, roll), which are relevant to 3D models, but only the first one (heading) is used for icons. For example, to remove all rotation, use: <gx:angles>0,0,0</gx:angles> (or <gx:angles>0</gx:angles> works for an icon).

    You will need to inject a <gx:angles>...</gx:angles> tag for each of the <when> and <gx:coord> tags in your track, and they go all in a group, right after the <gx:coord> tags. Should be relatively easy to do with a text editor, just find/count the number of <when> or <gx:coord> tags, and paste in that same number of <gx:angles> tags, like the example below.

    For more info on the use of <gx:angles>, see the KML Reference documentation for <gx:Track> and "Elements Specific to Track": https://developers.google.com/kml/documentation/kmlreference#elements-specific-to-track

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2">
    <Document>
      <name>Track angles sample</name>
      <open>1</open>
      <Style id="multiTrack">
        <IconStyle>
          <scale>1.2</scale>
          <Icon>
            <href>http://earth.google.com/images/kml-icons/track-directional/track-0.png</href>
          </Icon>
        </IconStyle>
        <LineStyle>
          <color>99ffac59</color>
          <width>8</width>
        </LineStyle>
      </Style>
      <Placemark>
        <name>Track no heading</name>
        <styleUrl>#multiTrack</styleUrl>
        <gx:Track>
          <when>2018-02-11T20:40:00Z</when>
          <when>2018-02-11T20:40:14Z</when>
          <when>2018-02-11T20:40:21Z</when>
          <when>2018-02-11T20:40:34Z</when>
          <when>2018-02-11T20:40:43Z</when>
          <when>2018-02-11T20:40:55Z</when>
          <when>2018-02-11T20:40:58Z</when>
          <when>2018-02-11T20:41:09Z</when>
          <when>2018-02-11T20:41:19Z</when>
          <when>2018-02-11T20:41:28Z</when>
          <when>2018-02-11T20:41:34Z</when>
          <when>2018-02-11T20:41:45Z</when>
          <when>2018-02-11T20:42:09Z</when>
          <when>2018-02-11T20:42:19Z</when>
          <when>2018-02-11T20:42:26Z</when>
          <when>2018-02-11T20:42:36Z</when>
          <when>2018-02-11T20:42:44Z</when>
          <when>2018-02-11T20:42:54Z</when>
          <when>2018-02-11T20:43:07Z</when>
          <when>2018-02-11T20:43:25Z</when>
          <when>2018-02-11T20:43:36Z</when>
          <when>2018-02-11T20:43:40Z</when>
          <when>2018-02-11T20:43:43Z</when>
          <when>2018-02-11T20:43:52Z</when>
          <gx:coord>-122.199034 37.848592 434.65</gx:coord>
          <gx:coord>-122.199048 37.848607 435.13</gx:coord>
          <gx:coord>-122.198994 37.848681 431.77</gx:coord>
          <gx:coord>-122.198893 37.848839 433.21</gx:coord>
          <gx:coord>-122.198838 37.84894 435.61</gx:coord>
          <gx:coord>-122.198777 37.849058 437.06</gx:coord>
          <gx:coord>-122.198761 37.849086 437.54</gx:coord>
          <gx:coord>-122.198706 37.849269 435.13</gx:coord>
          <gx:coord>-122.19871 37.849278 434.65</gx:coord>
          <gx:coord>-122.19872 37.849313 435.13</gx:coord>
          <gx:coord>-122.198712 37.849318 435.13</gx:coord>
          <gx:coord>-122.198682 37.849315 436.58</gx:coord>
          <gx:coord>-122.198669 37.849327 436.1</gx:coord>
          <gx:coord>-122.198529 37.849297 435.13</gx:coord>
          <gx:coord>-122.198439 37.849289 433.69</gx:coord>
          <gx:coord>-122.198284 37.849231 433.69</gx:coord>
          <gx:coord>-122.198191 37.849186 434.17</gx:coord>
          <gx:coord>-122.198076 37.849115 434.65</gx:coord>
          <gx:coord>-122.197967 37.849155 434.65</gx:coord>
          <gx:coord>-122.197937 37.849166 435.13</gx:coord>
          <gx:coord>-122.19793 37.849157 435.13</gx:coord>
          <gx:coord>-122.197881 37.849172 436.58</gx:coord>
          <gx:coord>-122.197844 37.849167 436.58</gx:coord>
          <gx:coord>-122.197708 37.849201 438.5</gx:coord>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
          <gx:angles>0</gx:angles>
        </gx:Track>
      </Placemark>
    </Document>
    </kml>