【问题标题】:angular-google-maps labels overlapse icons角谷歌地图标签重叠图标
【发布时间】:2014-11-25 03:57:42
【问题描述】:

所以我使用 angular-google-maps 库创建了一个角度应用程序,其中包括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>

这里是codepen example

【问题讨论】:

    标签: javascript angularjs google-maps google-maps-api-3 ionic-framework


    【解决方案1】:

    我为未来的读者修复了这个问题:

       //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
        }
     });
    

    labelclass css的内容

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

    【讨论】:

    • 嗨,@SjoerdDeWit,请问labelClass 在标记选项中的实际功能是什么? :)
    • 它用于将一个类传递给一个标签,因此它有一些默认的 css @Roylee
    • 在 ionic-3 应用程序中放置 css 类 .labelClass 的位置。组件的scss文件还是variable.scss文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多