Search code examples
javascriptgoogle-earth

Google Earth: Disable flyToView on runtime


I'm currently making an application where I use google earth to display a path. This path will be updated on a regular basis, and I've used a network link to connect the google earth to a KML file.

The problem is that every time google earth recieves an update from the KML it resets the view. I would like to disable this feature, but still be able to "fly" to a specific location on startup.

I've tried using setFlyToView(false) on the network link, but this results in no flying at all. What I would like, is for google earth to fly to the location of the placemark at start, and then when it updates -from the KML file through the network link- it doesn't fly anywhere.

Is there a way to access and change options when google earth is already running? If it's possible I could then use the setFlyToView(true) at initialization and then setFlyToView(false) when google earth has already changed the view to where I want to be, thereby disabling the updating of the view, but not the initial view position.

Thanks in advance!


Solution

  • That is the behavior if you have flyToView set 1 in the NetworkLink. Check that the flyToView element is child of the NetworkLink not the Link. Possibly the KML being generated by the JavaScript API you're using is not setting the flyToView correctly or it isn't supported.

    <Document>
      <visibility>1</visibility>
      <NetworkLink>
        <name>NE US Radar</name>
        <refreshVisibility>1</refreshVisibility>
        <flyToView>1</flyToView>
        <Link>...</Link>
      </NetworkLink>
    </Document>
    

    Also, you may want to override default view with a LookAt or Camera element added to the NetworkLink to fly.