棱角分明的谷歌地图标签覆盖了图标



所以我用angular谷歌地图库创建了一个angular应用程序,其中包括markerswithlabels目录,标签覆盖在图标上,这样你就可以看到另一个带标签图标顶部的另一个标签。现在我不想这个标签和图标隐藏在它后面,所以它只显示一个文本,

我创建了一个代码笔来显示我的意思:这是我设置标签的地方:

options: { 
      labelContent : dist + '<br />Overlapse',
      labelAnchor: "16 33",
      labelClass: 'labelClass',
      labelStyle: {opacity: 0.75},
      labelInBackground: true
    }, 

这个告诉标记目录给带有标签的用户标记:

<google-map ng-if="showloadedmap" center="map.center" draggable="true" maxZoom="map.maxZoom"
        minZoom="map.minZoom"  zoom="map.zoom" options="map.options" events="map.events">
      <markers models="map.markers" 
        doCluster="true" 
        coords="'self'"  
        icon="'icon'" 
        click="'onclicked'" 
                    options="'options'"
                    idkey='id' 
        clusterOptions='map.clusterOptions'
        isLabel='true'>     
      </markers>
    </google-map>

以下是代码笔示例

我为未来的读者修复了它:

   //1x1 img which is overlapsed by label
   var iconimg = {
        url: 'img/markers/'+value[8], // url
        scaledSize: new google.maps.Size(1, 1), // size
    };
    //icon as background image 
    var newstyle = {
        'background-image':'url("img/markers/'+value[8]+'")',
        'background-size': '36.5px 61px',
        'background-position': 'top left',
        'background-repeat': 'no-repeat'
    }

$scope.map.markers.push({
    id: value[3],
    latitude: angular.fromJson(value[1]),
    longitude: angular.fromJson(value[2]),
    icon: iconimg,
    title : value[0],
    options: {
        labelContent : dist + '<br />'+$filter('date')(date,'d-M'),
        labelAnchor: "36 61",
        labelClass: 'labelClass',
        labelStyle: newstyle,
        labelInBackground: false
    }
 });

标签类css 的内容

.labelClass {
    padding-top:29px;
    padding-left:2px;
    color:#000; 
    font-family: 'open_sansregular';
    height:61px; 
    width:37px;
    font-size:9px;
    line-height: 12px;
} 

最新更新