Google地球插件时间滑块保持运行状态

时间:2014-05-10 13:59:55

标签: google-earth-plugin

即使kmz文件结束,

Google地球插件时间滑块仍会继续运行。时间似乎永远不会手动停止。请参阅该页面 http://www.sodanjaljet.fi/kuhmo/

其他一些页面的代码代码基本相同,但不会保持运行,它会在kmz文件完成时结束,请参阅页面 http://www.sodanjaljet.fi/uncategorized/viipurinlahti-helmi-maaliskuussa-1940/

下面的问题代码

 <script src="https://www.google.com/jsapi"></script>
 <script type="text/javascript">
  var ge;
  var firsttime = 0;
  var timer;
  google.load("earth", "1", {"other_params":"sensor=false"});

  function init() 
  {
     google.earth.createInstance('map3d', initCB, failureCB);
  }

  function initCB(instance) 
  {
     var defaultRate = 1; // 1 second in the plugin for each real second.
     var speedyRate = 60*60*24*4; // 1 day for each real second.        
     ge = instance;
     ge.getWindow().setVisibility(true);        
     addSampleButton('Alkuun', camera);
     ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
     var href = 'http://www.sodanjaljet.fi/wp-content/uploads/kmz/Kuhmo2.kmz';
     google.earth.fetchKml(ge, href, function(kmlObject) {
           if (kmlObject)
              ge.getFeatures().appendChild(kmlObject);
           if (kmlObject.getAbstractView() !== null)
              ge.getView().setAbstractView(kmlObject.getAbstractView());
     });   
     ge.getTime().getControl().setVisibility(ge.VISIBILITY_SHOW); 
  }

  function failureCB(errorCode) 
  {
  }

  function camera() 
  {
    var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
    lookAt.setLatitude(63.95335);
    lookAt.setLongitude(30.08484);
    lookAt.setRange(20000.0); //default is 0.0
    lookAt.setTilt(30);
    lookAt.setHeading(0);
    ge.getView().setAbstractView(lookAt);  
    start();  
  }


  function setRate(rate)
  {
    var rate = 60*60*24*4;
    var extents = ge.getTime().getControl().getExtents();      
    if (firsttime == 0)
        start();
    firsttime = 1;
    ge.getTime().setRate(eval(rate));
  }

  function setRate2(rate)
  {
    var rate = 60*60*24*4;
    var time = ge.getTime().getTimePrimitive();
    ge.getTime().setRate(eval(0));
  }

  function addSampleButton(caption, clickHandler) 
  {
    var btn = document.createElement('input');
    btn.type = 'button';
    btn.value = caption;
    if (btn.attachEvent)
        btn.attachEvent('onclick', clickHandler);
    else
        btn.addEventListener('click', clickHandler, false);
    document.getElementById('sample-ui').appendChild(btn);
  }


  function start() 
  {
    var groundOverlay = ge.createGroundOverlay('');
    var timeSpan = ge.createTimeSpan('');
    timeSpan.getBegin().set('1940-01-01');
    timeSpan.getEnd().set('1940-01-03');
    groundOverlay.setTimePrimitive(timeSpan)
    ge.getFeatures().appendChild(groundOverlay);
    ge.getTime().setTimePrimitive(timeSpan);
  }

  google.setOnLoadCallback(init);

  </script>

代码工作正常,有播放,停止和“返回开始”按钮,它们工作。然而,不停止的时间是一个非常烦人的问题。 任何想法如何让它停止?

提前致谢。 BR jouko

0 个答案:

没有答案