Select to view content in your preferred language

Initializing the map is too slow

271
0
08-08-2023 02:55 AM
jianghan8098
New Contributor II

The initialization of the map is too slow, the initialization is successful only about 4s, and before the initialization is successful, the longitude and latitude conversion algorithm will be called abnormally

public static Vector3 GetUnityPosFromLatlon(ArcGISPoint latLon)
{
var cartesianPosition = arcGISMapComponent.View.GeographicToWorld(latLon);
Vector3 result = hPRoot.TransformPoint(cartesianPosition).ToVector3();

// Check for NaN values
if (float.IsNaN(result.x) || float.IsNaN(result.y) || float.IsNaN(result.z))
{
Debug.LogWarning("GetUnityPosFromLatlon returned NaN. Returning default value.");
return Vector3.zero; // Return a default value (0, 0, 0) in case of NaN
}

return result; // Return the calculated result

}

public static ArcGISPoint GetLatLonFromUnityPos(Vector3 vec)
{

var worldPosition = hPRoot.InverseTransformPoint(vec.ToDouble3());
ArcGISPoint result = arcGISMapComponent.View.WorldToGeographic(worldPosition);
if (double.IsNaN(result.X) || double.IsNaN(result.Y) || double.IsNaN(result.Z))
{
Debug.LogWarning("GetLatLonFromUnityPos returned NaN. Returning default value.");
return new ArcGISPoint(0,0,0); // Return a default value (0, 0, 0) in case of NaN
}
return result;

}

Can you tell me why it's taking so long to initialize

0 Kudos
0 Replies