Reputation: 765
Question :
Objective:
Environment :
What's done :
The KML file:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<name>Network Links</name>
<visibility>0</visibility>
<open>0</open>
<description>Network link for FPG </description>
<NetworkLink>
<name> NTFPG </name>
<visibility>0</visibility>
<open>0</open>
<description> The flight path generator </description>
<refreshVisibility>0</refreshVisibility>
<flyToView>0</flyToView>
<Url>
<href>viewCenteredPlacemark.py</href>
</Url>
</NetworkLink>
</Folder>
</kml>
#!/usr/bin/python
kml = (
'<?xml version="1.0" encoding="UTF-8"?>\n'
'<kml xmlns="http://www.opengis.net/kml/2.2">\n'
'<Placemark>\n'
'<name>Flight Path Generator</name>\n'
'<Point>\n'
'<coordinates>%.6f,%.6f</coordinates>\n'
'</Point>\n'
'</Placemark>\n'
'</kml>'
) %(-77.864,38.4556)
print 'Content-Type: application/vnd.google-earth.kml+xml\n'
print kml
I would like just to show the same position and see the GREEN dot on the network link, but it is RED , so clearly there is no parsing, whether that be due to the format of the KML file or something else. What am i missing ?
Upvotes: 0
Views: 1250
Reputation: 23778
If want the script to be executed in which it will generate KML, the script must be hosted by a web server (e.g. Apache).
If you access the python script locally from the file system without any web server involved then Google Earth will attempt to fetch viewCenteredPlacemark.py file as a KML text file and not execute it as a python script. This will not be parsed as KML and nothing will be displayed. If turn on error handling in Google Earth then you will see a parse error.
Just need a light-weight web server that can invoke a python script such as Apache httpd. There are many tutorials to configure a web server to run python scripts.
Example:
Upvotes: 1