Would like to display direction vectors at defined locations in Google Earth. In a 3D tool direction vectors differ from a position vector (i.e. 2 geographical points connected via a line) that the displayed size is independant of the zoom level, just dependant on the aspect angle (projection).
Side mote: Finally I would like to display 3 direction vectors which span a orthoganal coordinate frame. So each "vector" would point in 3D Space.
Any solution existing? Or any idea of workaround for it?
I am familiar with KML and already reached my first goal to display a ground track and to highlight areas of interests using polygons. However I have found no solution for my request.
You can create points with icon images that look like an arrow, and rotate them with the appropriate tags, like in the KML below. Try copy/pasting that into Earth Pro.
Note that in this example I used an easily available icon where the arrow points down, but you might want to use your own where the arrow points up, so that the icon heading matches the compass angle. Also, you can play with the icon hotspot tag, to define what part of the icon image is anchored at your point's lat/lon. In this case I used the center of the image, but you could use the origin or tip of the arrow if you wanted.
<?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" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>arrow icons with headings</name>
<Placemark>
<name>heading: 0</name>
<Style>
<IconStyle>
<scale>3</scale>
<heading>0</heading>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
</Icon>
<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Point>
<coordinates>-90,38</coordinates>
</Point>
</Placemark>
<Placemark>
<name>heading: 75</name>
<Style>
<IconStyle>
<scale>3</scale>
<heading>75</heading>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
</Icon>
<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Point>
<coordinates>-85,38</coordinates>
</Point>
</Placemark>
<Placemark>
<name>heading: 150</name>
<Style>
<IconStyle>
<scale>3</scale>
<heading>150</heading>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
</Icon>
<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Point>
<coordinates>-80,38</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Related
Someone shared a kml with me that was created in Google Earth Web along with a screenshot of it.
When I opened it up in Google Earth Pro, the colored polygons displayed as solid white.
For a test, I created a test polygon in Google Earth Web and exported it as KML.
Projects > New project > Create KML file
Draw line or shape > create polygon
Set fill color red at 75%
Set color 4px
Select export as KML
Same thing, the polygon shows up as a white box in Google Earth Pro.
The exported KML is structured like this:
<?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 xmlns:atom=http://www.w3.org/2005/Atom>
<Document>
<name>Untitled Project</name>
<gx:CascadingStyle kml:id="__managed_style_147D324643211BD21CEE">
<Style>
<IconStyle>
<Icon>
<href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&id=2000&scale=4</href>
</Icon>
<hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
</IconStyle>
<LabelStyle>
</LabelStyle>
<LineStyle>
<color>ffa21f7b</color>
<width>3.63636</width>
</LineStyle>
<PolyStyle>
<color>c02f2fd3</color>
</PolyStyle>
<BalloonStyle>
<displayMode>hide</displayMode>
</BalloonStyle>
</Style>
</gx:CascadingStyle>
...
<StyleMap id="__managed_style_0C1991940B211BD21CEE">
<Pair>
<key>normal</key>
<styleUrl>#__managed_style_147D324643211BD21CEE</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#__managed_style_2EB2C27FFE211BD21CEE</styleUrl>
</Pair>
</StyleMap>
<Placemark id="09A507D5E3211BD1D53F">
<name>Test Polygon</name>
<styleUrl>#__managed_style_0C1991940B211BD21CEE</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
0.0287244781654028,51.5286273373769,4.888032506075639 0.03124375777183053,51.52899071640604,5.649232085770059 0.03060716674301966,51.5305703663013,6.296306355936279 0.02835525808849049,51.53027540191405,5.649128389213159 0.0287244781654028,51.5286273373769,4.888032506075639
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
The <gx:CascadingStyle> does not appear in the KML reference.
https://developers.google.com/kml/documentation/kmlreference
What is going on here?
i am expecting the original colored polygon to appear in Google Earth Pro.
The <gx:CascadingStyle> is an undocumented element that is created in Google Earth Web that is unsupported by Google Earth Pro.
If you make a minor edit to the KML, then it will work as expected.
Make these changes:
Remove <Style> and </Style> elements.
Globally change <gx:CascadingStyle kml:id="xxx"> to <Style id="xxx">.
Replace <gx:CascadingStyle kml:id= with <Style id=
Replace </gx:CascadingStyle> with</Style>
Example:
Old:
<gx:CascadingStyle kml:id="__managed_style_147D324643211BD21CEE">
<Style>
...
</Style>
</gx:CascadingStyle>
New:
<Style id="__managed_style_147D324643211BD21CEE">
...
</Style>
You can globally make the changes to the KML using a text editor; e.g. Notepad++.
The KML is now valid with respect to the OGC KML 2.2 standard and will work in Google Earth Pro.
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.
I have some symbols that I want to add to a KML file (for Google Earth). However, my symbols consist of multiple icons overlayed on top of each other. For other maps that I use I simply draw the icons on top of each other and control the selection/right click actions so that the user only sees it as one object, but in Google Earth if I add each overlayed icon as a separate placemark the user sees multiple objects when they click on it. Is there a way to add a single placemark in kml with multiple icons?
I wanted to do something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<name>kmlTest</name>
<open>true</open>
<description>description</description>
<StyleMap id="Symbol0Map">
<Pair id="Symbol0MapPairNormal">
<key>normal</key>
<Style id="Symbol0normal">
<IconStyle id="Symbol0iconStyle">
<scale>1.0</scale>
<heading>0.0</heading>
<Icon>
<href>files/images/GenericGround_0.png</href>
</Icon>
<Icon>
<href>files/images/eqp_2.png</href>
</Icon>
</IconStyle>
<LabelStyle id="Symbol0labelStyle">
<color>FF00FFFF</color>
<colorMode>normal</colorMode>
<scale>0.0</scale>
</LabelStyle>
</Style>
</Pair>
<Pair id="Symbol0MapPairHighlight">
<key>highlight</key>
<!-- similar to above -->
</Pair>
</StyleMap>
<Folder>
<name>My Layers</name>
<visibility>true</visibility>
<open>true</open>
<Folder>
<name>My Layer</name>
<visibility>true</visibility>
<open>false</open>
<Folder>
<name>Symbols</name>
<visibility>true</visibility>
<open>false</open>
<Placemark id="Placemark0">
<visibility>true</visibility>
<open>false</open>
<description>Platform</description>
<styleUrl>#Symbol0Map</styleUrl>
<Point>
<coordinates>-123.1569,38.5962,0.0</coordinates>
</Point>
</Placemark>
</Folder>
</Folder>
</Folder>
</Document>
</kml>
where I just have multiple <Icon> tags (or multiple <IconStyle> tags). However, looking at the schema this is not valid and I tried it anyways and it only picks the last one.
Is this even possible or will I need to dynamically create rolled up icons in code and include those in my .kmz file?
A KML placemark can only have one icon image. You will need to combine (roll up) your icons into a single image and then apply that to the placemark.
I am able to display polygons, circles, etc etc, using KML.
Now i want to display only some Names using KML. Is this Possible ?
If you want to suppress displaying the label of placemarks (via KML) on the map of Google Earth then you can add a LabelStyle to your placemarks with a 0 scale (see sn_hide style in example below). If you want to suppress the label name on the map until you hover over the icon then StyleMaps are your best bet.
The first placemark in example below has its name shown in the places panel but hidden from the map using the LabelStyle. The second placemark #2 uses a StyleMap to hide the label until the user highlights or mouses over the icon in which it activates the highlight style showing the label. The third placemark #3 uses the default style that always shows the label.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Hide and show labels</name>
<Style id="sn_hide">
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="sh_style">
<LabelStyle>
<scale>1.1</scale>
</LabelStyle>
</Style>
<StyleMap id="msn_hide">
<Pair>
<key>normal</key>
<styleUrl>#sn_hide</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#sh_style</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<name>Placemark 1</name>
<description>Label name always hidden</description>
<styleUrl>#sn_hide</styleUrl>
<Point>
<coordinates>-119.232195,36.016021</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Placemark 2</name>
<description>Hover over place to show label</description>
<styleUrl>#msn_hide</styleUrl>
<Point>
<coordinates>-119.2324,36.0155</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Placemark 3</name>
<description>Always showing</description>
<Point>
<coordinates>-119.232672,36.014837</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I am looking to have two names for a placemark, one displayed when the placemark is hovered over, and one when it is not hovered over. The only information I've been able to find is changing the style (icon type, color, opacity, scale) for a highlighted placemark style. Any suggestions? Is this possible?
http://code.google.com/apis/kml/documentation/kml_tut.html#custom_styles
You could use custom icons to present a pseudo name (an image of the text you require) and another roll over pseudo name in the same manner.
This is called "styles for Highlighted Icons", to use it you would need to create and upload the two jpg images
nameImageOver.jpg
and
nameImageNormal.jpg
The kml would look like so:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Highlighted Icon</name>
<description>Mouse over to see the swap</description>
<Style id="highlightPlacemark">
<IconStyle>
<Icon>
<href>http://www.yourserver.com/nameImageOver.jpg</href>
</Icon>
</IconStyle>
</Style>
<Style id="normalPlacemark">
<IconStyle>
<Icon>
<href>http://www.yourserver.com/nameImageNormal.jpg</href>
</Icon>
</IconStyle>
</Style>
<StyleMap id="exampleStyleMap">
<Pair>
<key>normal</key>
<styleUrl>#normalPlacemark</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highlightPlacemark</styleUrl>
</Pair>
</StyleMap>
<Placemark>
<styleUrl>#exampleStyleMap</styleUrl>
<Point>
<coordinates>-122.0856545755255,37.42243077405461,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I have achieved this using the Google Earth API. Not sure how this plays in with using KML...
// On mouse over - show name
google.earth.addEventListener(placemark, 'mouseover', function(event) {
placemark.setName('My Placemark Label');
});
// On mouse out - hide (remove) name
google.earth.addEventListener(placemark, 'mouseout', function(event) {
placemark.setName('');
});