Friends, after I manually load the model locally, how can I set the loaded model to the specified latitude and longitude?
The easiest way is to add a CesiumGlobeAnchor component to it, and then set its longitudeLatitudeHeight
property.
Hi Kevin_Ring, I would like to ask how to set the latitude and longitude of an object while the program is running
You can set the longitudeLatitudeHeight
property on CesiumGlobeAnchor
component from a C# script at runtime. For example, say you had a MonoBehaviour
called MyScript
attached it to an object with a CesiumGlobeAnchor
. Then, in MyScript.cs
, you could write
CesiumGlobeAnchor globeAnchor = this.GetComponent<CesiumGlobeAnchor>();
globeAnchor.longitudeLatitudeHeight = new double3(longitude, latitude, height); // your values here
Hi janine, thank you very much for your help my problem was solved.
Hi janine, I have a new problem, I want to control the movement of objects by latitude and longitude, but I don’t know how to deal with it
Hi @kongyu,
I’m not sure I understand your problem. You can set the longitudeLatitudeHeight
of a CesiumGlobeAnchor
whenever you want, and with whatever values. So if you want to control their movement by longitude and latitude, just assign longitudeLatitudeHeight
a new value.
You can also enable “Detect Transform Changes” on the CesiumGlobeAnchor
if you would rather move the object in Unity coordinates. This makes the CesiumGlobeAnchor
detect any changes to its Unity transform. When it detects changes, it will recompute the longitude, latitude, and height of the globe anchor.
If you are only controlling the movement of an object via longitude and latitude coordinates, you should disable “Detect Transform Changes” on the object before moving it, so that it doesn’t apply any extra correction when you move the object.
Hi janine, Thank you for your answer, at that time, I felt that using the change of latitude and longitude to control the movement of the object would make the object teleport, but this did not happen, thank you very much for your answer.