动画D3地球(d3.geo.azimuthal) [英] Animating D3 globe (d3.geo.azimuthal)

查看:1243
本文介绍了动画D3地球(d3.geo.azimuthal)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于d3 javascript libarary的问题。我想使用方位角地球仪,而且我要从经度插入点和地球的坐标,使地球动画,而不使用鼠标事件。

I have question about the d3 javascript libarary. I want to use the azimuthal globe and I want to insert points from longitude and lattitude coordinates on the globe and make the globe be animated without ever using the mouse events.

你认为这是可能的吗?

Do you think this is possible? Can you give me some good tips on how to do this?

干杯
Thor

Cheers Thor

推荐答案

为了使示例轮换自己实现:

To make the example rotate on its own I implemented:

var newX = 185;
var newY = -200;

function setupRotate() {
    m0= [0,0];
    o0 = projection.origin();
  }

  function rotate() { 
    if (m0) {
      var m1 = [newX, newY];//d3.event.pageX, d3.event.pageY],
          o1 = [o0[0] + (m0[0] - m1[0]) / 8, o0[1] + (m1[1] - m0[1]) / 8];
      projection.origin(o1);
      //console.log(m1);
      circle.origin(o1)
      refresh();
      //console.log("rotate");
      //console.log("newX: "+newX+"  newY: "+newY);
    }
  }

function rotateInterval() {
    var theRotationInterval = setInterval(rotateAndIncrement,1);
    function rotateAndIncrement(){
      //console.log("rotateAndIncrement");
      if (newX === 3)//3065) {
      {
       //console.warn("!!Reset Rotation!!");
       clearInterval(theRotationInterval);
       newX = 185;
       rotateInterval();
      }
      //console.log("newX: "+newX+"  newY: "+newY);
      else {
        newX++;
        rotate();
      }
    }
  }

指向地图,它更复杂。如果我不能工作,我会回来这里。

I'm working on adding points to the map, it's much more complicated. If I cant get it working I'll post back here.

这篇关于动画D3地球(d3.geo.azimuthal)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆