Google MapsAPIv3でMarkerWithLabel拡張機能を使用しています。写真の下のラベルを中央揃えにしたいのですが。ラベルの位置を設定するLabelAnchorプロパティがあり、CSSlabelClassも次のように使用します。
var myMarker = new MarkerWithLabel(
{
position: latlng,
draggable: false,
raiseOnDrag: false,
map: map,
labelContent: "my text",
labelAnchor: new google.maps.Point(25, 0), //(25, 27),
labelClass: "my_label", // the CSS class for the label
labelStyle: {opacity: 0.8},
icon: image,
labelInBackground: true,
labelVisible: true,
clickable: true,
zIndex: 11
});
.my_label
{
color: black;
background-color: beige;
font-family: "Lucida Grande", "Arial", sans-serif;
font-size: 10px;
text-align: center;
width: auto;
white-space: nowrap;
padding: 4px;
border: 1px solid grey;
border-radius:3px;
box-shadow: 2px 2px 20px #888888;
}
ラベルボックスを自動整列することは可能ですか、それともテキスト幅を計算してLabelAnchorを手動で設定する必要がありますか?もしそうなら、どのようにテキスト幅を計算しますか?