如何在指南针上显示风向

How to show wind direction on a compass

本文关键字:显示 指南针      更新时间:2023-10-15

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

下面是我只使用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);
}​

HTML5及其Canvas将对此进行简短的处理。

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

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