2010-05-06 74 views
2

TLDR我想在我的開放圖層中旋轉特徵。
我希望它能夠面對我從服務器接收的某個標題。以編程方式旋轉特徵打開圖層


我知道,你可以對一個點的特徵旋轉或等:

window.setInterval(function() {rotateFeature(
     pointFeature, 360/20, origin)}, 100); 

open layers example.

但我希望能夠去面對它朝標題我得到了,所以。

  1. 我可以面向標題的功能嗎?
  2. 我可以以同樣的方式面對一個功能(圖像)嗎?
  3. 如果沒有,是否有可能自動計算所需的旋轉並將其定位?
  4. 或者我如何用圖像做到這一點的任何想法? (希望不要有360張)

一個例子或這種將理解:d預先

感謝。


至今沒有運氣使用:

 window.setInterval(function() {rotateFeature(
     imagefeature, 150/360, origin)}, 1000); 
     function rotateFeature(feature, angle, origin) { 
      feature.geometry.rotate(angle, origin); 
      } 

原屬是圖像對象的centeroid。

任何想法代碼的一面?

+0

我想旋轉圖像由「標題」我給。 – Sphvn 2010-05-14 04:05:58

回答

3

您可以使用圖像/圖標來表示矢量點,例如,

http://openlayers.org/dev/examples/vector-features.html

使用該PNG文件alt text http://openlayers.org/dev/img/marker.png 然後,您應該能夠在旋轉點在其他的例子。您可以旋轉到任何角度:

http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Geometry/Point-js.html#OpenLayers.Geometry.Point.rotate

rotate: function(angle,origin) 

繞另一個點。 參數

角度{浮法}旋轉角度以度(從正x軸逆時針測量的)

原點{OpenLayers.Geometry.Point}中心點旋轉

+0

感謝您的信息。但是如果我要旋轉一個點(圖像),我必須根據另一個點旋轉它,還是可以將它基於自身並旋轉它? – Sphvn 2010-05-10 07:40:00

+0

原點參數可以是任意點。要使用矢量特徵的質心(如果它是質心將成爲點的點),請使用: http://dev.openlayers.org/releases/OpenLayers-2。8/DOC/apidocs /文件/的OpenLayers /幾何/點js.html#OpenLayers.Geometry.Point.getCentroid – geographika 2010-05-10 10:27:08