0

Google Earth Pro: version 7.1.7.2602

Renderer: DirectX

I have one placemark that is a linear feature. The feature is a road, so I want to apply a style to it that sets its color and its physical width. When the style is defined in the same file as the placemark, the style is applied correctly. I see the desired color and physical width.

However, when the style is defined externally in another file, the style is not fully applied correctly. I see the desired color, but the physical width is not applied; the line width remains at the default.

The KML file that contains the placemark and the KML file that contains the external style are in the same directory. I know that the former KML file can find the latter KML file, because the color of the style is applied correctly.

Why does the physical width for the style not work when the style is external? Is it because physicalWidth property is an extended property (i.e., in the gx namespace)?

Things that I have tried to migitate the problem.

  • Closing and relaunching Google Earth.
  • Clearing both the memory and disk caches in Google Earth.
  • Giving the external style a different name than the in-file style, in case that was confusing Google Earth.

The following is a simple example that demonstrates the problem.

Example that works

Placemark and style are in the same file.

topeka2.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:gx="http://www.google.com/kml/ext/2.2"
     xmlns:kml="http://www.opengis.net/kml/2.2" >
  <Document>
    <name>topeka test 2</name>
    <description>Linear feature, in-file style</description>

    <Style id="road_big">
      <LineStyle>
        <color>ff00ffff</color>
        <gx:physicalWidth>50</gx:physicalWidth>
        <gx:outerWidth>0.25</gx:outerWidth>
        <gx:outerColor>88000000</gx:outerColor>
      </LineStyle>
    </Style>

    <Placemark>
      <name>road #1</name>
      <styleUrl>#road_big</styleUrl>
      <LineString>
        <coordinates>
          -95.706132,39.036977,0.0
          -95.706219,39.029695,0.0
          -95.696957,39.029696,0.0
          -95.696851,39.036896,0.0
        </coordinates>
      </LineString>
    </Placemark>

  </Document>
</kml>

Example that does not work

Placemark and style in different files.

topeka3.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:gx="http://www.google.com/kml/ext/2.2"
     xmlns:kml="http://www.opengis.net/kml/2.2" >
  <Document>
    <name>topeka test 3</name>
    <description>Linear feature, external style</description>

    <Placemark>
      <name>road #1</name>
      <styleUrl>topeka_styles.kml#road_big_external</styleUrl>
      <LineString>
        <coordinates>
          -95.706132,39.036977,0.0
          -95.706219,39.029695,0.0
          -95.696957,39.029696,0.0
          -95.696851,39.036896,0.0
        </coordinates>
      </LineString>
    </Placemark>

  </Document>
</kml>

topeka_styles.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" 
     xmlns:atom="http://www.w3.org/2005/Atom" 
     xmlns:gx="http://www.google.com/kml/ext/2.2" 
     xmlns:kml="http://www.opengis.net/kml/2.2" >
  <Document>
    <name>topeka styles</name>

    <Style id="road_big_external">
      <LineStyle>
        <color>ff00ff00</color>
        <gx:physicalWidth>50</gx:physicalWidth>
        <gx:outerWidth>0.25</gx:outerWidth>
        <gx:outerColor>88000000</gx:outerColor>
      </LineStyle>
    </Style>

  </Document>
</kml>

Screenshot

Following is a screenshot of Google Earth. The wide yellow road demonstrates that the in-file style works. The thin green road demonstrates that the physicalWidth of the external style does not work.

Google Earth screenshot

1
  • I think this is an important issue to resolve. It is either a bug, or there is something that I am not doing correctly in my markup that the KML documentation does not cover. Are there any Google developers on the wire that can comment?
    – Mike Finch
    Apr 4, 2017 at 22:59

1 Answer 1

2

Using the sample files you created, I was able to see the styles correctly applied only after using the 'Revert' command on the already loaded topeka3.kml file. If I deleted the file then closed Google Earth, I found I had to load the file twice again to get the styles to work correctly.

This bug was affecting my personal attempts at using an external file for styling. I also found that making a change to a style sheet would require me to load the style file itself into Google Earth, then Revert the referencing .kml files before the change would propagate to the main file containing placemarks.

Definitely a frustrating behavior.

1
  • Thank you @Seth_Gorham for the useful workaround of reverting the KML file that references external styles. That works for me. I got sidetracked and have not done any KML development since mid 2017. :)
    – Mike Finch
    Dec 5, 2019 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.