How can I get mouse position in the following format 157 degree 39 min 12.16498 sec W, 54 degree 0 min 29.87295 sec N?

Hello Team, I am figuring out way to convert the mouse position to this format
157 degree 39 min 12.16498 sec W, 54 degree 0 min 29.87295 sec N, is there any API in cesium.js to achieve this conversion ?
Or do we have to do this manually ? if manually how can I do it ?

@Gabby_Getz
Thank you !!

function findWorldCoordinate(position) {
    var ellipsoid = viewer.scene.globe.ellipsoid;
    var camera = viewer.camera;
    var cartesian = camera.pickEllipsoid(position || new Cesium.Cartesian2(0, 0));

    if (cartesian) {
        return ellipsoid.cartesianToCartographic(cartesian);
    }
    return new Cesium.Cartographic(0, 0, 0);
}

this is how I do it.
For more context have a look at this sandcastle.

To see it working, start dragging on the globe with the shift key down.
There are several built in functions to convert to different lat-lon notations. Have a look at the Cartesian classes in the documentation.

1 Like