viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-85.1641667, 29.9522222, 17000),
label : {
text : 'Philadelphia'
},
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([-87.39,30.91,-84.95,30.85,-84.19,27.14,-87.76,29.07,-87.39,30.91]),
material: Cesium.Color.RED.withAlpha(0.5),
height: 3000
}
});
try adding an eyeOffset to your label with a negative Z value
label : {
text : ‘Philadelphia’
eyeOffset : new Cesium.Cartesian3(0,0, -100)
}
eyeOffset : new Cesium.Cartesian3(0,0, -100) - it works but only in 3d. There is a problem with visibility of label in 2d. The label is below of polygon and polygon covers label and staying above the label but in 3d all is ok. Cesium version is 1.11.0. Here is an example of my code:
viewer.entities.add({
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([-73.42,45.11,-72.32,42.17,-76.42,40.04,
-79.77,37.86,-81.94,37.39,-81.96,38.90,-84.08,38.91,-80.36,41.37,
-79.55,43.53,-75.43,45.02,-73.42,45.11 ]),
material: Cesium.Color.RED.withAlpha(0.5),
},
position : Cesium.Cartesian3.fromDegrees(-78.1641667, 41.9522222),
label : {
text : 'Philadelphia',
eyeOffset : new Cesium.Cartesian3(0.0, 0.0, -100000),
},
});
3d - https://drive.google.com/file/d/0B8FAR4jw5j7DZGExMFhtY1cyd2s/view?usp=sharing
2d - https://drive.google.com/file/d/0B8FAR4jw5j7DYjEtVGQyaGhKeUE/view?usp=sharing
When I run that code here : http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Labels.html&label=Showcases
all is fine, but when I run the same code in my local, label in 2d is below of polygone. Maybe the problem is different version of Cesium because I've ran the same code in my local and here http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Labels.html&label=Showcases