代码之家  ›  专栏  ›  技术社区  ›  GeoCom

向铯多边形添加标签

  •  2
  • GeoCom  · 技术社区  · 9 年前

    这是我尝试的方式:(entity.polygon=true)

    static addLabel(entity) {
            entity.myLabel = new Cesium.LabelGraphics({
                position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
                label : {
                    text : 'Philadelphia',
                    font : '24px Helvetica',
                    fillColor : Cesium.Color.SKYBLUE,
                    outlineColor : Cesium.Color.BLACK,
                    outlineWidth : 2,
                }
            })
        }
    

    没有错误,但它没有显示在地图上。

    1 回复  |  直到 9 年前
        1
  •  3
  •   baloola    8 年前

    “标签”是实体的对象,请尝试以下操作:

    entity.label= new Cesium.LabelGraphics({
                position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
                text : 'Philadelphia',
                font : '24px Helvetica',
                fillColor : Cesium.Color.SKYBLUE,
                outlineColor : Cesium.Color.BLACK,
                outlineWidth : 2,
    
    
            })
    

    要隐藏它,请使用

    enity.label.show=false;