Select to view content in your preferred language

World position to unity position

455
1
11-27-2023 05:57 PM
e747362537
New Contributor

hello, everyone! I have some trouble with my scripts for Unity using.

I wrote a script to convert the latitude and longitude of ArcGIS Map into Unity world coordinates. My code is as follows.

e747362537_1-1701136162501.png

But when I was debugging, the following message appeared in my console of Unity.

e747362537_2-1701136242667.png

Latitude and longitude what my inputting are as follows.

e747362537_3-1701136365051.png

I am troubled by the above problems, if someone has such a problem to solve the idea can give me a message?

Thanks for the help,

Kind regards,

Tung.

 

 

0 Kudos
1 Reply
FlorianGrabner
New Contributor

ArcGISMapComponent globe = ...

var root = globe.gameObject.GetComponent<HPRoot>();
var view = globe.View;

double latitude = ...
double longitude = ...
double altitude = ...

ArcGISPoint geodLoc = new ArcGISPoint(longitude, latitude, altitude, ArcGISSpatialReference.WGS84())

double3 worldLoc = view.GeographicToWorld(geodLoc);

Vector3 universeLoc = (float3)root.TransformPoint(worldLoc);

The universeLoc is the position within the unity scene.

Be aware that the longitude is the first argument of ArcGISPoint.

0 Kudos