【问题标题】:google maps v3 markerwithlabel jquery rotate icons谷歌地图 v3 markerwithlabel jquery 旋转图标
【发布时间】:2012-09-24 09:52:24
【问题描述】:

是否可以获取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

标签: jquery google-maps-api-3


【解决方案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。

--山姆

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    • 2012-08-12
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多