谷歌地图v3 markerwithlabel jquery旋转图标

时间:2012-10-03 12:57:42

标签: jquery google-maps-api-3

是否可以获取markerwithlabel实用程序库对象的labelClass,然后使用jquery rotate来旋转它?

我一直在尝试这样的事情但是无法让它发挥作用......:

var markerx = new MarkerWithLabel({
        position: new google.maps.LatLng(0.0),
        draggable: false,
        raiseOnDrag: false,
        map: map,
        labelContent: "some chat",
        labelAnchor: new google.maps.Point(30, 20),
        labelClass: "labels", // the CSS class for the label
        labelStyle: {opacity: 1.0},
        icon: "/assets/swell_arrow.png",
        visible: true
       });
  $(document).ready(function()
        {
            $('.labels').rotate(30);
        }); 

感谢您的任何意见!

1 个答案:

答案 0 :(得分:1)

这就是我所做的:

var iconLabel = document.createElement("img");
    iconLabel.src = ImageFiles+"/icons/"+icn+"f.png";
    iconLabel.setAttribute("id","img"+$i);

var marker = new MarkerWithLabel({
    position: point,
    icon: Icons["blank"],
    shadow: Icons["blank"],
    draggable: false,
    map: theMap.map,
    flat: true,
    optimized: false,
    visible: true,
    labelContent: iconLabel , 
    labelAnchor: new google.maps.Point(16,16), 
    labelClass: "labels", 
    labelVisible: true,
    labelStyle: {opacity: 0.75}
});

Markers.length++;
Markers[$i] = marker;
Markers[$i].iLabel = iconLabel;

然后当我想要旋转时:

var tID = Markers[theIDX].iLabel.getAttribute("id");
$("#"+tID).rotate(parseFloat(heading));

它会旋转labelContent属性,而不是Class。

- 萨姆