How to get Longitude, Latitude and height data for the assets using Cesium.js API?

Hello Team,
I want get the position information for the assets that I upload on cesium ion in one of my project.
I am searching for a API in Cesium js which can provide me the Longitude, Latitude and Height values but did not find any, Is there such a API available ? If not how can I get the same information ?

Thanks !!
Looking for answers.

Hi @MUKUND_THAKARE,

Thanks for reaching out to the community with your question! Our API should be able to support your use case :grinning: :rocket:

What object are you using to add your asset to the scene? For instance, are you using the Entity object?

https://cesium.com/learn/cesiumjs/ref-doc/Entity.html?classFilter=entity

-Sam

1 Like

Hello @sam.rothstein,
I am loading a point cloud assets.
using this snippet.

const tileSet = new Cesium.Cesium3DTileset({
      url: Cesium.IonResource.fromAssetId(id),
});
this._viewer.scene.primitives.add(tileSet);
this._viewer.zoomTo(tileSet);

I could found the API to get the location information that I set for the point cloud in cesium ion.

Thanks !!

1 Like

Hi @MUKUND_THAKARE,

Thanks for sharing this code snippet with me!

I’m glad to hear that you were able to find the location of your point cloud. Would you mind sharing how you found the location with the rest of our community?

Best,
Sam

@sam.rothstein
Apologies for spelling mistake I forgot the “not”.
I did not find any API in cesium.js library, so the question is still open for entire community to answer.

Looking for answers, thanks !!

Hi @MUKUND_THAKARE,

Thanks for the clarification :laughing:

I did some more digging on my end. It seems like the key here is to change the translation of the 3D Tilesets transform matrix. Feel free to use this code as a reference for your solution:

const tileSet = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
        url : Cesium.IonResource.fromAssetId(id)
}));

let pos = {
    x: 12345.67,
    y: -12345.67,
    z: 12345.67,
};

tileset._root.transform[12] = viewer.camera.position.x - pos.x;
tileset._root.transform[13] = viewer.camera.position.y - pos.y;
tileset._root.transform[14] = viewer.camera.position.z - pos.z;

Best,
Sam

2 Likes