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);
        }); 

感谢您的任何意见!

4

1 回答 1

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。

--山姆

于 2012-10-09T18:28:15.137 回答