The effect of the following code is that kml uses networklink to continuously execute phython code on the server and dynamically change the longitude and latitude coordinates of points.
First, create a new virtual directory under the default website under Internet information service, and then create an application on the "virtual directory" tab under the directory, and then click "Configure ", go to "application configuration", click Add (for example), and click "OK.
Create the randomplacemark. py file in the resource manager of this directory. The Code is as follows:
#! C:/python25/python.exe #! The above changes to your own Python installation path
Import random
Latitude = random. randrange (-90, 90)
Longpolling = random. randrange (-180,180)
Kml = (
'<? XML version = "1.0" encoding = "UTF-8"?> \ N'
'<Kml xmlns = "http://www.opengis.net/kml/2.2"> \ N'
'<Placemark> \ N'
'<Name> random placemark </Name> \ N'
'<Point> \ N'
'<Coordinates> % d, % d </coordinates> \ N'
'</Point> \ N'
'</Placemark> \ N'
'</Kml>'
) % (Longpolling, latitude)
Print 'content-type: Application/vnd. google-earth.kml + XML \ N'
Print kml
Create a new file named test. kml.
<? XML version = "1.0" encoding = "UTF-8"?>
<Kml xmlns = "http://www.opengis.net/kml/2.2">
<Folder>
<Name> network links </Name>
<Visibility> 1 </visibility>
<Open> 0 </Open>
<Description> network link Example 1 </description>
<Networklink>
<Name> random placemark </Name>
<Visibility> 1 </visibility>
<Refreshvisibility> 1 </refreshvisibility>
<Open> 0 </Open>
<Description> A simple server-side script that generates a new random
Placemark on each call </description>
<Refreshvisibility> 0 </refreshvisibility>
<Flytoview> 1 </flytoview>
<Link>
<Href> http: // computername/virtual directory name/randomplacemark. py <Refreshmode> oninterval </refreshmode>
<Refreshinterval> 5 </refreshinterval>
<Viewrefreshmode> onstart </viewrefreshmode>
<Viewrefreshtime> 4 </viewrefreshtime>
</Link>
</Networklink>
</Folder>
</Kml>