viewer.camera.position gives you the position in which the camera is in X, Y, Z coordinates in meters relative to the center of the earth.
Depending on which story mode you are using, the approach is different:
Scene3D:
To see what the camera is looking at, you need to get the intersection point of the camera, which selects the beam and map.
function getMapCenter() { var windowPosition = new Cesium.Cartesian2(viewer.container.clientWidth / 2, viewer.container.clientHeight / 2); var pickRay = viewer.scene.camera.getPickRay(windowPosition); var pickPosition = viewer.scene.globe.pick(pickRay, viewer.scene); var pickPositionCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(pickPosition); console.log(pickPositionCartographic.longitude * (180/Math.PI)); console.log(pickPositionCartographic.latitude * (180/Math.PI)); }
Based on this thread .
Also try checking if the camera is looking at the map, not the sky.
SCENE2D:
This is a simple 2D view with a straight down camera.
From the docs:
2D mode. Map viewed from top to bottom with spelling
var camPos = viewer.camera.positionCartographic; console.log(camPos.longitude * (180/Math.PI)); console.log(camPos.latitude * (180/Math.PI));
Remaining 2.5D case or COLUMBUS_VIEW
source share