1

Google マップ v3 Javascript API で MarkerWithLabel を使用しています。

現在、カスタム マーカーを作成し、MarkerWithLabel の labelContent 属性を使用してアイコンを表示しています。見出しに応じてアイコンを動的に回転できるように、このようにします。それは完璧に機能します。

ここで、アイコンにもラベルを追加したいと思います。

私のコード:

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

var marker = new MarkerWithLabel({
    position: point,
    icon: boatIcons["blank"],
    shadow: boatIcons["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},
    labelInBackground: false
});

これにより、IMG罰金が作成されます。しかし、どのように DIV を作成し、それにテキストを追加してから、上記の IMG を追加してから、それをマーカーに追加するのですか?

4

1 に答える 1

1

私のコードから次のスニペットを見てください:-

var marker5 = new MarkerWithLabel({position: latlngE, 
    draggable: false,
    raiseOnDrag: false, 
    labelContent: "Pnt: 5",
    labelAnchor: new google.maps.Point(20, 0),
    labelClass: "labels",         // the CSS class for the label
    labelStyle: {opacity: 0.75},
    icon: {url: './images/arrows/Dot.png',
    size: new google.maps.Size(20, 20),
    origin: new google.maps.Point(0, 0)},
    marker: MarkerWithLabel});

重要なのは、次のオプションを指定することです: marker: MarkerWithLabel

http://code.google.com/p/jquery-ui-map/wiki/jquery_ui_map_v_3_tutorialをご覧ください

于 2013-04-12T08:38:56.523 に答える