如何在指南针上显示风向

时间:2012-07-17 15:51:39

标签: javascript jquery jquery-ui compass-geolocation

我正在开发一个Web应用程序,我必须显示温度,湿度,风速,风向等。我正在使用google.visualization.Gauge()来显示其他内容,但我想显示风向罗盘。有没有人知道我可以用于网站/ webapp的任何(jQuery / javascript / etc)指南针? 感谢

2 个答案:

答案 0 :(得分:5)

这是我使用CSS的方法。使用变换来旋转针。 DEMO您还可以使用jQuery Rotate插件。

HTML

<div id="compass">
  <div id="arrow"></div>
</div>​

CSS

#compass {
  width: 380px;
  height: 380px;
  background-image:url('http://i.imgur.com/44nyA.jpg');
  position: relative;
}
#arrow {
  width: 360px;
  height: 20px;
  background-color:#F00;
  position: absolute;
  top: 180px;
  left: 10px;
  -webkit-transform:rotate(120deg);
  -moz-transform:rotate(120deg);
  -o-transform:rotate(120deg);
  -ms-transform:rotate(120deg);

  -moz-transition: all 1s ease;
  -webkit-transition: all 1s ease;
  -o-transition: all 1s ease;
  transition: all 1s ease;
}

#compass:hover #arrow {
  -webkit-transform:rotate(0deg);
  -moz-transform:rotate(0deg);
  -o-transform:rotate(0deg);
  -ms-transform:rotate(0deg);
}​

答案 1 :(得分:1)

HTML5和它的Canvas将做很多工作。

http://www.tutorialspoint.com/html5/canvas_drawing_lines.htm

我只是为了完整性而在这里发帖,我个人仍然坚持使用javascript库。