Google Maps V3 MarkerWithLabel jQuery旋转图标

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

感谢您的任何意见!

也许你可以尝试使用CSS transform旋转图像。 - Timeless
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。

--Sam


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接