回答

6
  1. 为了在一个谷歌地图,以显示一个箭头,你可以创建一个Rich Marker,使用google-maps-utility-library-v3嵌入图像,
  2. 下一页在程度上应用旋转的图像元素与CSS3 tranformations。

在例如:

 

// content element of a rich marker 
var richMarkerContent = document.createElement('div'); 

// arrow image 
var arrowImage   = new Image(); 
arrowImage.src   = 'http://www.openclipart.org/image/250px/' + 
          'svg_to_png/Anonymous_Arrow_Down_Green.png'; 

// rotation in degree 
var directionDeg   = 144 ; 

// create a container for the arrow 
var rotationElement  = document.createElement('div'); 
var rotationStyles  = 'display:block;' + 
          '-ms-transform:  rotate(%rotationdeg);' + 
          '-o-transform:  rotate(%rotationdeg);' + 
          '-moz-transform:  rotate(%rotationdeg);' + 
          '-webkit-transform: rotate(%rotationdeg);' ; 

// replace %rotation with the value of directionDeg 
rotationStyles   = rotationStyles.split('%rotation').join(directionDeg); 

rotationElement.setAttribute('style', rotationStyles); 
rotationElement.setAttribute('alt', 'arrow'); 

// append image into the rotation container element 
rotationElement.appendChild(arrowImage); 

// append rotation container into the richMarker content element 
richMarkerContent.appendChild(rotationElement); 

// create a rich marker ("position" and "map" are google maps objects) 
new RichMarker(
    { 
     position : position, 
     map   : map, 
     draggable : false, 
     flat  : true, 
     anchor  : RichMarkerPosition.TOP_RIGHT, 
     content  : richMarkerContent.innerHTML 
    } 
); 
 
+0

由于塞巴斯蒂安。我一直在寻找一种快速简便的方式来旋转标记,这对我来说是最好的选择。第二个感谢你的工作示例。 – 2012-10-26 22:39:33