Search code examples
kmlgoogle-earthgoogle-earth-plugin

Spinning Globe in Google Earth Plugin, Accounting For Range/Zoom


I am trying to spin the Google Earth Plugin globe via code. I am using a 3rd party controller in order to move it, embedded in a WPF application which is calling JavaScript functions.

My ideal solution is to simulate the HUD buttons exactly. I'd like the globe to behave exactly as if I hit a HUD button when I tell it "spin right" or "spin down". Is that possible?

As I've not found out a solution to the above, I've created a few methods spinning the globe via a series of calls to 'lookAt.setLongitude()'. The basics of the solution being that I add a certain amount to the Longitude (or Latitude) each time I call the JavaScript function.

My problem is that I've not figured out how to account for range (aka: how close/far away the user has zoomed)! When a certain distance, adding "25" to the Longitude works great -- but get further or closer to the surface of the globe and the solution falls apart quickly!

Is there an automatic way I can account for the range, or does anyone have any pointers on a good algorithm for adjusting the Lat/Long movements based on the current range?

Thank you!


Solution

  • There is no automatic way you can account for the range to make the globe appear to move by the same ammount at different zoom levels. Basically, if you are moving the view by 25 degrees then that is how much you are moving the view.

    If you wish to increase the amount moved based on the range then simply use the range as a variable somewhere in the calculation. You should at least post some code and say why it isn't working if you do try this and get stuck.

    EDIT

    Another option may be to simply simulate the key-press that would rotate the globe for you. Depending on your set up you should be able to send one of the arrow keys, or one of the control keys a, w,s or d thus making the plug-in rotate just as if you had pressed the button on the HUD.