KML icons on every waypoint - kml

I want to export telephone poles and cables out of our database into a KML file for Google Earth.
For every node we have an array of poles, the cables are always connected towards the next pole in the array.
An export making simple paths seems to be easy enough. But these paths just show a path, they don't show every waypoint (telephone pole).
This is an example in Google Maps what I want to achieve in .kml

If you want paths and points for each of the poles (aka waypoints) then you need your KML to include not only the line segments separate points for each of the positions of the poles.
Your KML will need to be structured like this where poleSyle will have an IconStyle with the icon you want for the points and lineStyle will be a thick green line
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="poleStyle">
...
</Style>
<Style id="lineStyle">
...
</Style>
<Placemark>
<styleUrl>#lineStyle</styleUrl>
<LineString>
<coordinates>...</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>pole1</name>
<description>address pole1</description>
<styleUrl>#poleStyle</styleUrl>
<Point>
<coordinates>...</coordinates>
</Point>
</Placemark>
...
</Document>
</kml>
If you don't want or need a unique name or description for every point then you can combine the points in a single Placemark inside a MultiGeometry like this:
<Placemark>
<styleUrl>#poleStyle</styleUrl>
<MultiGeometry>
<Point>
<coordinates>...</coordinates>
</Point>
<Point>
<coordinates>...</coordinates>
</Point>
</MultiGeometry>
</Placemark>

Related

KML Layer Ordering

I have created KML files from esri Shapefiles to be used in google earth. The issue is when I bring in the two files bottom set of polygons will show the lines over the top polygons hiding a portion of the area.
I have seen people reference something about code but I was hoping someone could offer a different non-coding solution or explain better where this code would go and how it works.
Its not making sense to me.
I have tried changing the position of the two layers but any way doesn'f bring the smaller set of polygons to the top.
What I am looking for is the smaller set of polgyon lines to be completely visible while on top and the larger polygon set to be behind the first one
If you want one polygon to always be on top of another where both are clampedToGround then the gx:drawOrder property should be used.
Note the documentation (see below) only specifies LineStrings but also works for Lines, LinearRings, and Polygons. Anywhere "LineStrings" is mentioned below just replace it with Lines, Rings, and Polygons. The drawOrder support for Polygons is undocumented but is implemented in Google Earth nevertheless.
KML Documentation:
<gx:drawOrder>
"An integer value that specifies the order for drawing multiple line
strings (or polygons). LineStrings drawn first may be partially or fully
obscured by LineStrings with a later (or higher) draw order. This element may
be required in conjunction with the <gx:outerColor> and <gx:outerWidth>
elements in <LineStyle> when dual-colored lines cross each other."
In example below, the Red polygon is drawn over the blue polygon. To make the blue polygon draw over the red one change its drawOrder value to a higher number.
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<Placemark>
<name>Red Polygon</name>
<description>gx:drawOrder=3</description>
<Style>
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>ff0000ff</color>
</PolyStyle>
</Style>
<Polygon>
<gx:drawOrder>3</gx:drawOrder>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
14.456906,37.345497,0 14.949769,37.346531,0
14.960918,37.987563,0 14.45089,37.987521,0
14.456906,37.3455,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Blue Polygon</name>
<description>gx:drawOrder=2</description>
<Style>
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>ffff0000</color>
</PolyStyle>
</Style>
<Polygon>
<gx:drawOrder>2</gx:drawOrder>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
14.83626,38.016863,0 14.835535,37.645589,0
15.47025,37.589266,0 15.470457,38.019158,0
14.83626,38.016862,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>

LabelStyle.... Why won't this code produce red font on half size labels?

I'm doing a proof-of-concept map. Goal is half sized labels, with red font, and no icon. I've tried everything, even copy pasting from the google KML reference manuals and many examples posted here. What am I missing? I'm trying to display the map in both Google's "My maps" and also as a called data file at the browser utility gmap4. The test map should show four labels with Google streetmap of Pennsylvania for a baselayer...... Thanks for any help.
<?xml version="1.0" standalone="yes"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Style id="NoIconRedTextHalfSize">
<IconStyle>
<scale>.1</scale>
<Icon>
<href>https://maps.google.com/mapfiles/kml/paddle/grn-stars.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<Color>FF1400FF</Color>
<Scale>.5</Scale>
</LabelStyle>
</Style>
<Folder>
<Placemark>
<name>Hs-4-C.Sonney</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-5-B.Jozwiak</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-6-B.Roae</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Hs-7-M.Longietti</name>
<styleUrl>#NoIconRedTextHalfSize</styleUrl>
<Point>
<coordinates>1,1,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
The KML syntax includes a number of tags that are not supported by plain Google maps (my map) or by sotfware based on the Google map API. One of the non-supported tags is .
See: https://developers.google.com/maps/documentation/javascript/kmllayer#supported-elements
To make a label with no icon try making a transparent icon.

Google kml gx:drawOrder

<?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">
<Document>
<Style id="Line1">
<LineStyle>
<color>ffff0000</color>
<width>4</width>
</LineStyle>
</Style>
<Style id="Line2">
<LineStyle>
<color>ff00ff00</color>
<width>4</width>
</LineStyle>
</Style>
<Style id="Poly1">
<PolyStyle>
<color>ff0000ff</color>
</PolyStyle>
</Style>
<Style id="Poly2">
<PolyStyle>
<color>ffffffff</color>
</PolyStyle>
</Style>
<Placemark>
<name>Line 1</name>
<styleUrl>#Line1</styleUrl>
<LineString>
<coordinates>
-112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357
</coordinates>
<gx:drawOrder>2</gx:drawOrder>
</LineString>
</Placemark>
<Placemark>
<name>Polygon 1</name>
<styleUrl>#Poly1</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357
</coordinates>
</LinearRing>
</outerBoundaryIs>
<gx:drawOrder>4</gx:drawOrder>
</Polygon>
</Placemark>
<Placemark>
<name>Line 2</name>
<styleUrl>#Line2</styleUrl>
<LineString>
<coordinates>
-112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357
</coordinates>
<gx:drawOrder>4</gx:drawOrder>
</LineString>
</Placemark>
<Placemark>
<name>Polygon 2</name>
<styleUrl>#Poly2</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-112.265654928602,36.09447672602546,2357
-112.2660384528238,36.09342608838671,2357
-112.2668139013453,36.09251058776881,2357
-112.2677826834445,36.09189827357996,2357
-112.2688557510952,36.0913137941187,2357
-112.2694810717219,36.0903677207521,2357
-112.2695268555611,36.08932171487285,2357
-112.2690144567276,36.08850916060472,2357
-112.2681528815339,36.08753813597956,2357
-112.2670588176031,36.08682685262568,2357
-112.2657374587321,36.08646312301303,2357
</coordinates>
</LinearRing>
</outerBoundaryIs>
<gx:drawOrder>8</gx:drawOrder>
</Polygon>
</Placemark>
</Document>
</kml>
So As you can see in the above kml I've tried to use the gx:drawOrder element to sort the line strings & the polygons into drawing layers. BUT... if you load this in the kml interactive sampler or even Google Earth (free desktop edition) the geometry primitives only z order sort among "like primitives". That is, the line strings are sorted only against other line strings and the polygons are only sorted against other polygons.
In this case you can see that both "line 1" and "line 2" have draw orders of < "Polygon 2" & I as such I was expecting "polygon 2" to draw over the top of everything. But that is NOT the case.
In the end I've had to use altitude values to implement the z order that I want, but it's quite an unsatisfactory solution as most people view kml geometry using an isometric projection & the altitude values cause my geometry to skew.
What I'd like to know is this:
Is this the expected behavior of gx:drawOrder? The document around the element is sparse & it even says that it's only applicable to the line string, but according to the xsd is should be applicable to all geometry primitives (which it appears to be... well at least to polygons as well anyway...)
Is there a way to get the gx:drawOrder to be applicable over all
geometry primitives?
Thanks in advance!
The KML documentation only mentions <gx:drawOrder> with respect to line strings not polygons nor does it mention the behavior of drawOrder across different geometries (lines, rings, and polygons). The drawOrder support for Polygons is undocumented but was reported as an issue in the bug tracker.
You would naturally expect the drawOrder to work the same over all geometry primitives, but looks like Google Earth draws the features in groups by type: polygons, then ground overlays, followed by lines and point data where drawOrder is applied only within a group. ScreenOverlays are drawn last so they are always on top.
This means that a polygon with drawOrder=2 overlapping a line with drawOrder=1 still shows the polygon under the line. Also, even if a polygon has a higher value drawOrder and overlaps a GroundOverlay (aka Image Overlay), the polygon is drawn first and hidden under the GroundOverlay.
gx:DrawOrder is not part of the OGC KML 2.2 standard. It's a Google KML Extension so Google defines how it works. Also means Google can change how it works.

Animating a line in Google Earth using kml

I am pretty accomplished at using the animated update function of google earth and am using it to move models around. What I would really like to do is to be able to animate a line (eg up and down) in Google Earth but am finding this tricky.
I have the longitude and latitude of the line at the start. For example line coordinates are:
-88,17,100 -88.20270841086835,17.21899813162266,100
I then want to raise one end of this line up to an altitude of 500 over a period of 5 seconds.
I've drawn the line using LineString:
<Placemark id="path1">
<name>Untitled Path man</name>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-88.,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
But Im now lost as to how to use <gx:AnimatedUpdate> to move one end up from 100 to 500.
Im sure its easy - can someone point me in the right direction??
The trick is to update the LineString element (with an id on that) rather than the Placemark.
Here's a working KML example tour that animates a line changing from a relative altitude of 100 to 500m.
<?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">
<Document>
<name>gx:AnimatedUpdate example</name>
<open>1</open>
<LookAt>
<longitude>-88.1351880996469</longitude>
<latitude>17.09943637744042</latitude>
<altitude>0</altitude>
<heading>49.91874373078863</heading>
<tilt>84.43764019949967</tilt>
<range>1929.311316966288</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<Placemark>
<name>Untitled Path man</name>
<LineString id="path1">
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
<gx:Tour>
<name>Play me!</name>
<gx:Playlist>
<gx:AnimatedUpdate>
<gx:duration>5</gx:duration>
<Update>
<targetHref/> <!-- Left empty to refer to the current file -->
<Change>
<LineString targetId="path1">
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,500
</coordinates>
</LineString>
</Change>
</Update>
</gx:AnimatedUpdate>
<!-- Wait for the animation to complete (see the touring
tutorial for an explanation of how AnimatedUpdate's
duration isn't enough to guarantee this). -->
<gx:Wait>
<gx:duration>5.0</gx:duration>
</gx:Wait>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
For details see https://developers.google.com/kml/documentation/touring#tourtimelines

Getting lines to work on Google Earth

So I've been sifting through GE's documentation, and found how to do LineStyle and LineString to style and display a line, but in practice I cannot actually make it work. Here's my KML:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document><Style id="thisStyle">
<LineStyle>
<color>500078F0</color>
<colorMode>Normal</colorMode>
<width>5</width>
</LineStyle>
</Style>
<Placemark>
<name>502-2012-11-19 05:27:03</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0513,42.0894,247</coordinates>
</Point>
</Placemark>
<Placemark>
<name>502-2012-11-19 05:26:46</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0517,42.0886,287</coordinates>
</Point>
</Placemark>
....
<Placemark>
<name>525-2012-11-19 04:38:25</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0512,42.0894,178</coordinates>
</Point>
</Placemark>
<styleUrl>#thisStyle</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
....
-76.0512,42.0894,178
</coordinates></LineString></Document></kml>
Note: The above places where "..." appears there are about 50 more coordinate sets, I removed them for the sake of brevity, but since all coordinates are produced by a script if one works I know they all will. Can anyone nudge me in the right direction as to why my placemarks all show up, but no lines?
A LineString element is only valid inside a Placemark (or a MultiGeometry inside a Placemark):
<Placemark>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
-76.0512,42.0894,178
</coordinates>
</LineString>
</Placemark>
Example on Google Maps with your KML
Example on Google Maps with a Placemark containing the Linestring
You must either inline Style in the Placemark or reference the style in the Placemark using styleUrl element.
The last Placemark in your example needs to be rewritten like this:
<Placemark>
<name>525-2012-11-19 04:38:25</name>
<description>Speed:0</description>
<styleUrl>#thisStyle</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247
-76.0517,42.0886,287
...
-76.0512,42.0894,178
</coordinates>
</LineString>
</Placemark>
If your KML doesn't view correctly then it usually helps to validate the KML. You can use the KML Validator.

Resources