Placemark name(label) not appearing in Google Earth - kml

I have a KML file with some locations, the problem is that the names are not displayed beside the placemark in Google Earth.
KML Part
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="feverlocs" id="feverlocs">
<SimpleField name="block" type="string"></SimpleField>
<SimpleField name="lat" type="float"></SimpleField>
<SimpleField name="long" type="float"></SimpleField>
</Schema>
<Folder><name>feverlocs</name>
<Placemark>
<ExtendedData><SchemaData schemaUrl="#feverlocs">
<SimpleData name="block">Garhi</SimpleData>
<SimpleData name="lat">29.598867</SimpleData>
<SimpleData name="long">79.469856</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>79.469856,29.598867</coordinates></Point>
</Placemark>
<Placemark>
<ExtendedData><SchemaData schemaUrl="#feverlocs">
<SimpleData name="block">SodaSaroli</SimpleData>
<SimpleData name="lat">30.278907</SimpleData>
<SimpleData name="long">78.137521</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>78.137521,30.278907</coordinates></Point>
</Placemark>
I am not able to understand the problem.
So basically SodaSaroli should appear on it's placemark

Only the <name> field appears as a label on the map as defined in the KML. The ExtendedData elements would appear in the description balloon when a placemark is clicked unless you have an explicit description element.
The scope of the name is described in the KML Reference.
If want name to appear then need to add <name> field to the placemarks:
<Placemark>
<name>SodaSaroli</name> ***
<ExtendedData><SchemaData schemaUrl="#feverlocs">
<SimpleData name="block">SodaSaroli</SimpleData>
<SimpleData name="lat">30.278907</SimpleData>
<SimpleData name="long">78.137521</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>78.137521,30.278907</coordinates></Point>
</Placemark>

Related

Updating existing KML through a hyperlink in description

I am using Google Earth 5.0 Client. I would like to update a KML file (loaded by a NetworkLink) by clicking on a hyperlink in the description/balloonStyle tag of one of its placemarks.
Here is an example:
A.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml>
<NetworkLink>
<Link>
<href>http://www.example.com/B.kml</href>
</Link>
</NetworkLink>
</kml>
B.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml>
<Document>
<Folder id="entities">
<Folder id="en1_folder">
<Placemark id = "en1_point">
<description>
<a href="http://www.example.com/getConnections.php?en=id1"
type="application/vnd.google-earth.kml+xml"> Get connections </a>
</description>
<Point>
<coordinates>...</coordinates>
</Point>
</Placemark>
</Folder>
There are about 500 such folders, each with its corresponding en# point
containing a description hyperlink.
</Folder>
</Document>
</kml>
If a user clicks on a hyperlink, I want to generate a set of LineStrings connecting that point to one or more other points.
For example, getConnections.php?en=id1 could generate a response like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml>
<Update targetHref="http://www.example.com/B.kml">
<Change>
<Folder targetId="en1_folder">
<Placemark id="en1_connections">
<LineString>
<Coordinates>
(en1_coords), (en5_coords), (en7_coords)
</Coordinates>
</LineString>
</Placemark>
</Folder>
</Change>
</Update>
</kml>
This doesn't work in GE 5.0. I understand that Update is a child of NetworkLinkControl which in turn must be requested by a NetworkLink from the same domain as the KML that contains it.
I know there are several workarounds using one or more NetworkLinks, however I am curious to know if there still exists a way to directly update the same KML file by clicking on the description hyperlink.
Any thoughts appreciated.
Thanks,
Max

KML file in Google Earth shows name of entity replacement

I've got a question referring to the BalloonStyle Tutorial in the KML documentiation:
BalloonStyle Documentation
Playing around with this KML file:
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>ExtendedData+SchemaData</name>
<open>1</open>
<!-- Create a balloon template referring to the user-defined type -->
<Style id="trailhead-balloon-template">
<BalloonStyle>
<text>
<![CDATA[
<h2>My favorite trails!</h2>
<br/><br/>
The $[TrailHeadType/TrailHeadName/displayName] is <i>$[TrailHeadType/TrailHeadName]</i>.
The trail is $[TrailHeadType/TrailLength] miles. <br/>
The climb is $[TrailHeadType/ElevationGain] meters. <br/><br/>
]]>
</text>
</BalloonStyle>
</Style>
<!-- Declare the type "TrailHeadType" with 3 fields -->
<Schema name="TrailHeadType" id="TrailHeadTypeId">
<SimpleField type="string" name="TrailHeadName">
<displayName><![CDATA[<b>Trail Head Name</b>]]></displayName>
</SimpleField>
<SimpleField type="double" name="TrailLength">
<displayName><![CDATA[<i>The length in miles</i>]]></displayName>
</SimpleField>
<SimpleField type="int" name="ElevationGain">
<displayName><![CDATA[<i>change in altitude</i>]]></displayName>
</SimpleField>
</Schema>
<!-- Instantiate some Placemarks extended with TrailHeadType fields -->
<Placemark>
<name>Easy trail</name>
<styleUrl>#trailhead-balloon-template</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#TrailHeadTypeId">
<SimpleData name="TrailHeadName">Pi in the sky</SimpleData>
<SimpleData name="TrailLength">3.14159</SimpleData>
<SimpleData name="ElevationGain">10</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-122.000,37.002</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Difficult trail</name>
<styleUrl>#trailhead-balloon-template</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#TrailHeadTypeId">
<SimpleData name="TrailHeadName">Mount Everest</SimpleData>
<SimpleData name="TrailLength">347.45</SimpleData>
<SimpleData name="ElevationGain">10000</SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-121.998,37.0078</coordinates>
</Point>
</Placemark>
</Document>
</kml>
When you remove one of the SimpleData elements, Google Earth shows the Entity Replacement from the Balloon Template. For example you remove the line <SimpleData name="ElevationGain">10000</SimpleData>
it shows up in the Balloon like "The climb is $[TrailHeadType/ElevationGain] meters." Which doesn't look very nice.
Any idea how to tell Google Earth, that it shouldn't display the line from the balloon, if there is a missing SimpleData?
Thanks in Advance
I don't think* you can do what you are asking here - i.e. apply conditional logic within this style text. I have had a similar requirement in the past (certain pieces of data were missing from some of my placemarks) and I ended up applying different styles for each of the possible scenarios of missing information when generating the KML.
It felt both very clunky and if you have a large number of scenarios of one or more items being missing while others exist it could quickly be a mess.
*Would love to be wrong.
UPDATE
Just looked at my code for this, and I actually ended up putting all the text in the placemark fields of my schema, and printing out empty nodes when I did not have data - also less elegant, but did not require additional styles in the end. Based on your example something like:
<BalloonStyle>
<text>
<![CDATA[
<h2>My favorite trails!</h2>
$[TrailHeadType/TrailHeadName/displayName]
$[TrailHeadType/TrailLengthBalloonText]
$[TrailHeadType/ElevationGainBalloonText]
]]>
</text>
</BalloonStyle>
<Placemark>
<name>Difficult trail</name>
<styleUrl>#trailhead-balloon-template</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#TrailHeadTypeId">
<SimpleData name="TrailHeadName">Mount Everest</SimpleData>
<SimpleData name="TrailLength">347.45</SimpleData>
<SimpleData name="ElevationGain">10000</SimpleData>
<SimpleData name="TrailHeadNameBalloonText"><![CDATA[The trail name is Mount Everest</br>]]></SimpleData>
<SimpleData name="TrailLengthBalloonText"><![CDATA[The trail is 347.45 miles.</br>]]></SimpleData>
<SimpleData name="ElevationGainBalloonText"><![CDATA[The climb is 10000 meters.</br>]]></SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-121.998,37.0078</coordinates>
</Point>
</Placemark>
Then when you have no data you leave that item blank:
<Placemark>
<name>Difficult trail</name>
<styleUrl>#trailhead-balloon-template</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#TrailHeadTypeId">
<SimpleData name="TrailHeadName">Mount Everest</SimpleData>
<SimpleData name="TrailLength">347.45</SimpleData>
<SimpleData name="ElevationGain">10000</SimpleData>
<SimpleData name="TrailHeadNameBalloonText"><![CDATA[The trail name is Mount Everest</br>]]></SimpleData>
<SimpleData name="TrailLengthBalloonText"></SimpleData>
<SimpleData name="ElevationGainBalloonText"></SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<coordinates>-121.998,37.0078</coordinates>
</Point>
</Placemark>
As my data are changing somehow quite often, I'm now providing a xml file linked to an css file and embed it as an iframe in the description. For offline use, create a kmz and put the xml and css into it.
For a small tutorial have a look here:
http://www.w3schools.com/xml/xml_display.asp
In the kml, it looks as follows:
<description>
<![CDATA[
<iframe src="http://www.w3schools.com/xml/cd_catalog_with_css.xml"></iframe>
]]>
</description>

kml, High Performance KML for Maps and Earth, not working

I made a KML file to mimic an example from "
High Performance KML for Maps and Earth'-on YouTube-link (at 15:11-16:05 or just 15:51)
I get the error:
Validation stopped at line 2, column 45: no declaration found for element 'kml'
When I try to run this code GOOGLE EARTH crashes.
Here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<gx:Track>
<when>13:51</when>
<gx:coord>-147.871 64.861</gx:coord>
<ExtendedData>
<SchemaData schemaUrl="#schema">
<gx:SimpleArrayData name="PM 2.5">
<gx:value>0.0</gx:value>
<gx:value>-6.0511e+15</gx:value>
<gx:value>180</gx:value>
</gx:SimpleArrayData>
</SchemaData>
</ExtendedData>
</gx:Track>
</Placemark>
<Placemark>
<gx:Track>
<when>13:56</when>
<gx:coord>-147.871 64.861</gx:coord>
<ExtendedData>
<SchemaData schemaUrl="#schema">
<gx:SimpleArrayData name="PM 2.5">
<gx:value>0.0</gx:value>
<gx:value>-1.0001e+16</gx:value>
<gx:value>180</gx:value>
</gx:SimpleArrayData>
</SchemaData>
</ExtendedData>
</gx:Track>
</Placemark>
</kml>
This is a shorter version of my actual full kml file
You are not using a correct format for the KML file
Firstly, while this is correct for most cases
<kml xmlns="http://www.opengis.net/kml/2.2">
I prefer to use this (I forget why but I do)
<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">
but your main problem is you are also missing a <Document>
so the actual file should look 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>Name</name>
<Placemark>
...
</Placemark>
</Document>
</kml>

Changing placemark balloons for hundreds of points

I have a KML file with individual placemarks for gas station locations in the the city. (I had created this in GeoMedia and exported to KML).
I would like to revise the balloon style of each of the placemarks to something similar to one of these balloon styles -
http://earth.google.com/outreach/tutorial_balloon.html
Is there any manner in which I can apply the balloon style to each placemark in the file? Would I have to do it point by point, or can I place the balloon style at the top of the file and have the other placemarks reference that style?
I am very new to KML so any insight would be appreciated.
Thanks
#Matt - I have used your suggestions and tried various iterations but just cant seem to get it right. The file already has the placemarks created - and I want to just edit the style which includes adding logo, remove the directions, and so on.
The new style appears, but the schema text is not appearing in the placemark balloon.
I have pasted some of the code below - any thoughts would be appreciated.
<Schema name="" id="Schema20">
<SimpleField type="xsd:int" name="Building_ID"></SimpleField>
<SimpleField type="xsd:string" name="Building Name"></SimpleField>
<SimpleField type="xsd:string" name="Street Address"></SimpleField>
<SimpleField type="xsd:string" name="Office Type"></SimpleField>
<SimpleField type="xsd:double" name="GFA (m2)"></SimpleField>
<SimpleField type="xsd:string" name="GFA_(sqft)"></SimpleField>
<SimpleField type="xsd:int" name="Storeys"></SimpleField>
<SimpleField type="xsd:int" name="Year Built/Occupied">
</SimpleField></Schema>
<Style id="TestStyle">
<BalloonStyle>
<bgColor>ffffffbb</bgColor>
<text><![CDATA[<b><font color="#CC0000" size="+3">$[name]</font></b><br/><br/>
<font face="Courier">$[description]</font><br/><br/> $[geDirections] ]]>
</text>
</BalloonStyle>
</Style>
<Folder>
<name>Office Buildings</name>
<Placemark>
<name>539</name>
<styleUrl>#TestStyle</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#Schema20">
<SimpleData name="Building_ID">111</SimpleData>
<SimpleData name="Building Name">Name</SimpleData>
<SimpleData name="Street Address">Address</SimpleData>
<SimpleData name="Office Type">Secondary Office</SimpleData>
<SimpleData name="GFA (m2)">100</SimpleData>
<SimpleData name="GFA_(sqft)">1000</SimpleData>
<SimpleData name="Storeys">5</SimpleData>
<SimpleData name="Year Built/Occupied">2010</SimpleData>
</SchemaData>
</ExtendedData><Point>
<coordinates>-122.370533,37.823842,0</coordinates></Point>
</Placemark>
..... 1000 more like this
#Matt -
What I am running into is that if I use in the balloon style, then the data from the Schema which I referenced in my earlier post does not appear in the balloon.
If I leave the blank then the Schema will appear in the balloon.
Do you know how I can have both appear?
Thanks,
<BalloonStyle>
<text>
<![CDATA[<img align="right" src="http://www.website.com/logo.jpg" width="175">]]>
$[description]
</text>
<bgColor>ffffffbb</bgColor>
</BalloonStyle>
you can use styleUrl for you placemarks (which you will need to apply to all of your placemarks that you want to have a selected style):
<styleUrl>#someIDforStyle</styleUrl>
if the style section is in a different file then just add in the link:
<styleUrl>styles\pathToFile\StyleFile.kml#someIDforStyle</styleUrl>
both above will link a certain Style with that ID similar to:
<Style id='someIDforStyle'>
<BalloonStyle>
<text>
<![CDATA[ ....
your are going to want to add html here to make your balloons similar to that link
...
]]>
</text>
</BalloonStyle>
</Style>
you might check this kml link out for adding Custom Data: https://developers.google.com/kml/documentation/extendeddata

Google Earth elevation profile and the missing values

I have some nice data from research aircrafts that I put into kml-files like the example below. If you check the elevation profile, you find the
extended Data plotted nicely.
My problem: my data contains missing values. If I try an empty in place of the missing data, the extended data doesn't appear
more in the profile frame (you can delete one of the floats in the gx-value pair to see).
My question to you: Is there any hack to make GoogleEarth draw the profile without the missing values (i.e. interrupted)?
Or do you know a way to give the GE developers a feedback?
<?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" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document id="feat_1">
<Style id="stylesel_0">
<LineStyle>
<color>ff0000ff</color>
<colorMode>normal</colorMode>
<width>4</width>
</LineStyle>
</Style>
<visibility>1</visibility>
<Schema id="schema_1" name="Flight Track">
<gx:SimpleArrayField name="bb" type="int">
<displayName>Flight Track</displayName>
</gx:SimpleArrayField>
</Schema>
<Placemark id="feat_2">
<name>example</name>
<styleUrl>#stylesel_0</styleUrl>
<gx:Track>
<gx:coord>-140.0 10.0 0.0</gx:coord>
<gx:coord>-133.572123903 7.66044443119 4131.75911167</gx:coord>
<gx:coord>-130.15192247 1.73648177667 9698.46310393</gx:coord>
<gx:coord>-131.339745962 -5.0 7500.0</gx:coord>
<gx:coord>-136.579798567 -9.39692620786 1169.77778441</gx:coord>
<gx:coord>-143.420201433 -9.39692620786 1169.77778441</gx:coord>
<gx:coord>-148.660254038 -5.0 7500.0</gx:coord>
<gx:coord>-149.84807753 1.73648177667 9698.46310393</gx:coord>
<gx:coord>-146.427876097 7.66044443119 4131.75911167</gx:coord>
<gx:coord>-140.0 10.0 5.99864288729e-28</gx:coord>
<altitudeMode>absolute</altitudeMode>
<ExtendedData>
<SchemaData schemaUrl="#schema_1">
<gx:SimpleArrayData name="ext">
<gx:value>0.00217237382056</gx:value>
<gx:value>0.107224360838</gx:value>
<gx:value>1.99669920652</gx:value>
<gx:value>14.0278818114</gx:value>
<gx:value>37.1819210687</gx:value>
<gx:value>37.1819210687</gx:value>
<gx:value>14.0278818114</gx:value>
<gx:value>1.99669920652</gx:value>
<gx:value>0.107224360838</gx:value>
<gx:value>0.00217237382056</gx:value>
</gx:SimpleArrayData>
</SchemaData>
</ExtendedData>
</gx:Track>
</Placemark>
</Document>
</kml>
This does look like a bug.
I have created an issue at http://code.google.com/p/earth-issues/issues/detail?id=1399
If you star it then you will be notified of any updates.
Meanwhile you may wish to preprocess your KML data and place interpolated values where you have missing ExtendedData.

Resources