I want to show altitude like "Pick position"
Here is my code. I have used billboards to show icons but I am getting this erro - Uncaught TypeError: Cesium.Cartographic.fromCartesian is not a function
var pinBuilder = new Cesium.PinBuilder();
var bluePin = viewer.entities.add({
name : icon_name,
position : Cesium.Cartesian3.fromDegrees(coordinates_array[0],coordinates_array[1]), //log1+","+lati1
billboard : {
image : pinBuilder.fromText(icon_name,Cesium.Color.fromRgba('0x'+flight_color_code).withAlpha(0.5), 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});
/***************************************************************/
var scene = viewer.scene;
var handler;
if (!scene.pickPositionSupported) {
console.log('This browser does not support pickPosition.');
}
var labelEntity = viewer.entities.add({
label : {
show : false,
showBackground : true,
font : '14px monospace',
horizontalOrigin : Cesium.HorizontalOrigin.LEFT,
verticalOrigin : Cesium.VerticalOrigin.TOP,
pixelOffset : new Cesium.Cartesian2(15, 0)
}
});
// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var foundPosition = false;
var scene = viewer.scene;
if (scene.mode !== Cesium.SceneMode.MORPHING) {
var pickedObject = scene.pick(movement.endPosition);
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.id === bluePin) {
console.log(pickedObject.id,"----------------------");
var cartesian = viewer.scene.pickPosition(movement.endPosition);
if (Cesium.defined(cartesian)) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian.position);
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
var heightString = cartographic.height.toFixed(2);
labelEntity.position = cartesian;
labelEntity.label.show = true;
labelEntity.label.text =
'Lon: ' + (' ' + longitudeString).slice(-7) + '\u00B0' +
'\nLat: ' + (' ' + latitudeString).slice(-7) + '\u00B0' +
'\nAlt: ' + (' ' + heightString).slice(-7) + 'm';
labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, -cartographic.height * (scene.mode === Cesium.SceneMode.SCENE2D ? 1.5 : 1.0));
foundPosition = true;
}
}
}
if (!foundPosition) {
labelEntity.label.show = false;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
Not sure where is the error.
Thanks