KML Network Link - Fly To

I am developing an application that runs Google Earth with a KML file that links to other local files through <NetworkLink> , which updates the time interval. I am trying to identify a KML file that will center the map (fly) in a specific place.

A "network link" has a tag that is sent to the first label or FlyTo inside the file. However, this will execute the fly when the file is updated, which in my case, when the time interval expires. Is there a way I can get the fly-to command to execute only when the associated network file changes, and not every time? Is there a way to get Fly To to process only once until the linked file somehow changes? My NetworkLink file is defined as follows:

  <NetworkLink> <name>My Fly To Request</name> <Link> <href>MyFlyTo.kmz</href> <refreshMode>onInterval</refreshMode> <refreshInterval>2</refreshInterval> </Link> </NetworkLink> 

The application will often be updated with a specific mark on which information will be focused when the user asks. This is not a static label that needs to be focused, but one that will change frequently.

+4
source share
1 answer

I think you could achieve this using a combination of the ID and NetworkLinkControl and Update attributes in Kml.

MyFlyToRequest.kml contains NetworkLink, which downloads a data file that contains your data, it has a flyToView element set to true. Please note that the network link also has a request identifier

MyFlyToRequest.kml

 <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <NetworkLink id="request"> <name>My Fly To Request</name> <Link> <href>http://www.yourserver.com/MyFlyTo.kmz</href> <refreshMode>onInterval</refreshMode> <refreshInterval>2</refreshInterval> </Link> <flyToView>1</flyToView> </NetworkLink> </kml> 

The second file MyFlyTo.kmz is the one that is downloaded. It has your current data as it is. However, it also has an additional NetworkLink, which downloads a new third file.

MyFlyTo.kmz - Edited

 <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document id="data"> <visibility>1</visibility> <NetworkLink> <name>Update MyFlyToRequest</name> <Link> <href>http://www.yourserver.com/TurnOffFlyTo.kml</href> </Link> </NetworkLink> <Placemark> <name>This is flown to once (hopefully)</name> <Point> <coordinates>52,0,0</coordinates> </Point> </Placemark> </Document> </kml> 

The new third TurnOffFlyTo.kml file is part of the configuration key; it contains NetworkLinkControl , which targets the NetworkLink request in the first MyFlyToRequest.kml file. It simply sets the flyToView element to 0.

TurnOffFlyTo.kml

 <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <NetworkLinkControl> <Update> <targetHref>http://www.yourserver.com/MyFlyToRequest.kml#request</targetHref> <Change> <NetworkLink id="request"> <!-- turn off the flyto behaviour --> <flyToView>0</flyToView> </NetworkLink> </Change> </Update> </NetworkLinkControl> </kml> 

The final TurnOnFlyTo.kml file redirects flyto behavior again.

TurnOnFlyTo.kml

 <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <NetworkLinkControl> <Update> <targetHref>http://www.yourserver.com/MyFlyToRequest.kml#request</targetHref> <Change> <NetworkLink id="request"> <!-- turn off the flyto behaviour --> <flyToView>1</flyToView> </NetworkLink> </Change> </Update> </NetworkLinkControl> </kml> 

The logic is this.

  • MyFlyToRequest.kml loads MyFlyTo.kml
  • flyto on, so the view moves the first first label, etc. in MyFlyTo.kml
  • The link in MyFlyTo.kml loads TurnOffFlyTo.kml.
  • Update in TurnOffFlyTo.kml three disables flyto in MyFlyToRequest.kml.
  • File one, updated, file two loaded ...

If you need to enable flyto again, you just upload file four. If the data in MyFlyTo.kmz is generated by you, this will be a simple case of loading TurnOnFlyTo.kml, where TurnOffFlyTo.kml is called.

All that was said is not verified and, as such, may not work as it is, although in principle I do not understand why this is not so.

If this sounds like something you can try here, these are some resources that should help.

NetworkLinkControl Reference

http://code.google.com/apis/kml/documentation/kmlreference.html#networklinkcontrol

Using Updates

http://code.google.com/apis/kml/documentation/updates.html

+2
source

All Articles