小编Mag*_*nus的帖子

MarkerWithLabel标签中心对齐

我在Google Maps API v3中使用了MarkerWithLabel扩展.我想将图片下方的标签设置为居中对齐.有一个LabelAnchor属性设置标签的位置,我也使用CSS labelClass,如下所示:

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 …
Run Code Online (Sandbox Code Playgroud)

center alignment google-maps-api-3

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

alignment ×1

center ×1

google-maps-api-3 ×1