I am trying to update a kml file through the networkcontrollink with an update
The kml file i want to update is stored on the server is called initial_coord.kml.
<?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>
<Placemark id="pm123">
<name>point123</name>
<Point>
<coordinates>-95.44,40.42,0</coordinates>
</Point>
</Placemark>
<Placemark id="pm456">
<name>point456</name>
<Point>
<coordinates>-95.43,40.42,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
The kml file i load to update it is the following:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>Update</name>
<Link>
<href>http://localhost/cgi-bin/testF/add_more_coords.py</href></Link>
</NetworkLink>
</kml>
And the python script i am calling is the following
#!/usr/bin/python
kml= (
'<?xml version="1.0" encoding="UTF-8"?>\n'
'<kml xmlns="http://www.opengis.net/kml/2.2">\n'
'<NetworkLinkControl>\n'
'<Update>\n'
'<targetHref>http://10.10.210.247/initial_coords.kml</targetHref>\n'
'<Change>\n'
'<Placemark targetId="pm123">\n'
'<name>Name changed by Update Change</name>\n'
'<!-- coordinates remain the same -->\n'
'</Placemark>\n'
'</Change>\n'
'</Update>\n'
'</NetworkLinkControl>\n'
'</kml>\n'
)
print 'Content-Type: application/vnd.google-earth.kml+xml\n'
print kml
The update does not work and i am wondering why because it is very similar to the google example
The NetworkLinkControl is strict regarding the target URL and you have localhost in the root KML and 10.10.210.247 in the python-generated output. Most match exactly to work correctly.
<Link>
<href>http://localhost/cgi-bin/testF/add_more_coords.py</href></Link>
</NetworkLink>
<Update>
'<targetHref>http://10.10.210.247/initial_coords.kml</targetHref>\n'
<Update>
You'll notice the targetUrl and NetworkLink URL matching in the tutorial.
Try putting the IP address in the root KML file to match what is generated in the python.
<NetworkLink>
<Link>
<href>http://10.10.210.247/cgi-bin/testF/add_more_coords.py</href>
</Link>
</NetworkLink>
<Update>
'<targetHref>http://10.10.210.247/cgi-bin/testF/add_more_coords.py</targetHref>\n'
<Update>
Related
I'm using this KML file (lets call it load.kml)
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<refreshVisibility>1</refreshVisibility>
<flyToView>1</flyToView>
<Link> <href>C:\\Users\\bridenstinek\\workspace\\AlertServlet\\resources\\outboundKML\\test.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>20</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
To point Google Earth to a kml file (lets call it test.kml). When I load test.kml regularly (without using load.kml) the range I set works correctly (the zoom level is how I set it).
But when test.kml gets loaded using load.kml the range is incorrect. The placemark zooms in really far and ignores the range I set in the test.kml file.
Is there something overriding the range inside load.kml?
Example of test.kml:
<?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" xmlns:location="http://example.com">
<Document>
<name>Example</name>
<Style id="alertKMLStyle">
<BalloonStyle>
<text><![CDATA[<center>
<b><font color="#CC0000" size="+8">$[name]</font></b>
<br/></center><br/>
<font size="+2">$[description]</font>
<br/><br/>
]]></text>
</BalloonStyle>
</Style>
<Placemark>
<name>Example Name</name>
<description>Example Description</description>
<LookAt>
<location:coordinates>800</location:coordinates>
<longitude>2.294</longitude>
<latitude>48.858</latitude>
<altitude>0.5</altitude>
<heading>12.23742976490019</heading>
<tilt>0</tilt>
<range>115718.4889366544</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#alertKMLStyle</styleUrl>
<gx:balloonVisibility>1</gx:balloonVisibility>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>2.294,48.858,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
There are a few undocumented differences when you load KML directly as opposed to via a NetworkLink.
When you load the KML via the NetworLink it looks for a LookAt or Camera in the outermost element which is the Document in test.kml file.
You can either 1) copy/move the <LookAt> from the Placemark to the parent Document element in test.kml or 2) copy the <LookAt> and insert into the NetworkLink in load.kml and make flyToView=0.
If the target KML has timestamps then the behavior via Networklinks is different then loading it directly. See related issue.
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
I am trying to create a route based off lon & lat's. This is what i have so far, but it doesn't seem to be working correctly.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<PlaceMark>
<name>test</name>
<description>test Desc</description>
<Point>
<coordinates>-80.54400115,43.4250264</coordinates>
<coordinates>-80.52674314,43.43127701</coordinates>
...
</Point>
</PlaceMark>
</Document>
<kml>
Is the syntax correct? When i load it up in my maps app, it doesn't show the route.
Please see the KML reference
KML is XML which is case sensitive (PlaceMark is not the same as Placemark)
a <Point> is a single location
a line is a <LineString>
Your XML needs to be valid (</kml> is needed to close the opening <kml>).
example
KML from example above on Google Maps
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Document>
<Placemark><name>test</name>
<description>test Desc</description>
<LineString>
<coordinates>
-80.54400115,43.4250264
-80.52674314,43.43127701
-80.5274517,43.43458707
-80.53223781,43.43876923
-80.54385782,43.44993036
-80.53949137,43.45723788
-80.53950793,43.46780893
-80.53352615,43.4730443
-80.53491389,43.47816267
-80.54136061,43.48417145
-80.54163034,43.48439869
</coordinates>
</LineString>
</Placemark></Document>
</kml>
The jurisdiction I live in published data using a Google globe. The kml file they point to contains
<?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">
<gx:GoogleMapsEngineLink>
<href>http://globe.information.qld.gov.au/qldglobe</href>
</gx:GoogleMapsEngineLink>
</kml>
I can't find any reference to the gx:GoogleMapsEngineLink in any public documentation and I am having trouble using that with other standard kml, for example a Place. I'd like a kml that pens this government globe and also adds a Place.
I'd like to be able to add this Place to the Above kml (ie. one kml file)
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns="http://www.opengis.net/kml/2.2"
<Placemark>
<description>Some nice place</description>
<Point>
<coordinates>153.0064595002,-27.4811714996,0</coordinates>
</Point>
<Style>
<LabelStyle>
<color>ff7fffff</color>
</LabelStyle>
</Style>
</Placemark>
</kml>
The Google KML extensions can be found in Google's KML documentation:
https://developers.google.com/kml/documentation/kmlreference#kmlextensions
The complete XML schema for elements in this extension namespace is located at http://developers.google.com/kml/schema/kml22gx.xsd.
gx:GoogleMapsEngineLink is not a documented part of the Google KML extensions as defined in the namespace http://www.google.com/kml/ext/2.2.
Why don't you create a KMZ file with a root KML file and the gx:GoogleMapsEngineLink loaded in a KML embedded in the KMZ file as an auxiliary file.
Root KML file doc.kml:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<NetworkLink>
<Link>
<href>engine.kml</href>
</Link>
</NetworkLink>
<Placemark>
<description>Some nice place</description>
<Point>
<coordinates>153.0064595002,-27.4811714996,0</coordinates>
</Point>
<Style>
<LabelStyle>
<color>ff7fffff</color>
</LabelStyle>
</Style>
</Placemark>
</Document>
</kml>
And the google engine KML (engine.kml) like this:
engine.kml:
<?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">
<gx:GoogleMapsEngineLink>
<href>http://globe.information.qld.gov.au/qldglobe</href>
</gx:GoogleMapsEngineLink>
</kml>
Update: Since the <gx:GoogleMapsEngineLink> is special and undocumented it doesn't work as would other KML elements so it cannot appear as child to <Document> element or as target to <NetworkLink>. Likewise, if this element appears at the root level with a Document or Placemark following those Features are ignored.
Google announced it will discontinue the Google Maps Engine product in January 2016.
I could not get my KML to Validate as valid XML because my KML includes a gx (Google Extension) tag (<gx:Tour> for example), and www.google.com/kml/ext/2.2/ is a 404 error.
Here is what I finally got to validate after an hour of trial and error:
<?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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/kml/ext/2.2 http://developers.google.com/kml/schema/kml22gx.xsd">
I don't really know what I'm doing exactly, so I can't make any claims this is a kosher or legitimate fix, or whether that's all necessary. But it's the only way I could get it to validate.
I want to load a kml file every 10 seconds with google earth, I found this example http://ukhas.org.uk/code:kml_live_update but it seems it does not work.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<Link>
<href>every10.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>10</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
It does not load every10.kml, even I tried a kml file over internet (http://code.google.com/apis/kml/documentation/Point.kml )
The code you provided from the example is valid, but the link reference (href) is incorrect. You should try inserting a full URL, and it will work. Using the Point.kml file you provided, the working code should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<Link>
<href>http://code.google.com/apis/kml/documentation/Point.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>10</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
First - it is working example.
You must specify full link to your kml file.
In my version GE this NetworkLink update every 10 sec. In your case, for refresh view (and new update kml), you may try to setup settings in Google Earth. On context menu on subelement of kml file (NetFolder icon), you may choose Refresh tab (maybe other name - i have language differen from English) and choose 10 sec interval.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<NetworkLink>
<Link>
<href>every10.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>10</refreshInterval>
</Link>
</NetworkLink>
</kml>
Worked for me:
load.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<Link>
<href>C:\Users\loran\kml\every10.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>10</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
Just make sure you have a full path in your href
It is loading but doesn't zoom in where the point is so it looks like its not working. The real problem is loading point continuoulsy with zoom to that particular region