javascript - 在 Cesium 中为多边形添加标签

标签 javascript ecmascript-6 cesiumjs czml

如何在指定位置向实体(例如多边形)添加标签:

这就是我尝试的方法:(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,
            }
        })
    }

没有错误,但没有显示在 map 上。

最佳答案

“标签”是实体的一个对象,所以试试这个:

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;

关于javascript - 在 Cesium 中为多边形添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45077010/

相关文章:

javascript - Chrome Native Messaging API chrome.runtime.connectNative 不是函数

php - 验证粘贴在字段中的脚本

javascript - 如何继承和重写angularjs(java pendent)中的 Controller 方法?

javascript - 商店更改后 React redux UI 未更新

javascript - 对解构函数参数感到困惑

javascript - “箭头功能”和“功能”是否等效/可互换?

javascript - Cesiumjs 从矢量计算俯仰、偏航、航向

javascript - Backbone.js,无法渲染 View

webgl - 如何从 geoserver 获取 3dmodesl(dae,obj,etc) 作为图层

javascript - 改变圆柱体的长度或拉伸(stretch)圆的高度