Topic: Line Renderer Exact Position on the Map.
Hi Alex, We did some stress test trying to find the limit of markers rendered on a map instance, and we reach the limit of around 1000 to 1024 markers on a single map with an acceptable frame rate dropping. After that number (1024) the app throw a timeout exception on mobile devices tested. Just to let you know, one of our clients has approximately 51k waypoints in 48 hiking tracks.
The plan is to have the waypoints painting the tracks on the map with a quite accurate detail because the hiking tracks are placed in the middle of nowhere in the countryside, justified the number of waypoints. We've planned dividing the tracks in stages with up to 1000 waypoins each and put it all together in a cluster or group, but it's not worth because we're just moving the problem ahead to the backend team.
We decided to follow with LineRenderer that solved our problem without compromising the frame rate too much, adding the possibility of having more control over the line colors, width and simplify positions i.e. The LineRenderer solution fits very well in this case.
The problem we found it's the same as here: https://forum.infinity-code.com/viewtopic.php?id=1570.
How to place the LineRenderer exactly on the map? Noticing that this is also mirrored.
Attached you´ll find the LineRenderer Inspector with the positions values after converted, the pink line rendered anywhere on the world, and the map with the red line rendered with OnlineMapsDrawingLine, where the LineRenderer should appear
The code we're using:
private void GetData()
{
_tracks = File.ReadAllText(m_JsonPath);
Tracks _waypoints = JsonUtility.FromJson<Tracks>(_tracks);
Debug.Log("waypoints Loaded" + _waypoints);
int length = 0;
length = _waypoints.points.Length;
Debug.Log("Lenght is: " + length);
LineRenderer lineRenderer = map.AddComponent<LineRenderer>();
lineRenderer.useWorldSpace = true;
lineRenderer.widthCurve = AnimationCurve.Constant(0, length, 2);
lineRenderer.positionCount = length;
lineRenderer.startWidth = 2.0f;
lineRenderer.endWidth = 2.0f;
lineRenderer.numCapVertices = capEnds;
lineRenderer.numCornerVertices = capCurves;
Debug.Log("Line Renderer");
List<Vector2> linepoints = new List<Vector2>();
foreach (Waypoints tracks_ in _waypoints.points)
{
Debug.Log("lat: " + tracks_.longitude + " Long:" + tracks_.latitude);
float longx = float.Parse(tracks_.longitude);
float laty = float.Parse(tracks_.latitude);
string name = tracks_.stageId;
linepoints.Add(new Vector2 (longx, laty));
}
for (int i = 0; i < linepoints.Count; i++)
{
Debug.Log("Where we´re drawing the line:" + linepoints[i].ToString());
Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPosition(linepoints[i].x, linepoints[i].y);
Debug.Log("Where we´re drawing the line after convertion: " + p.x.ToString() + " " + p.z.ToString());
lineRenderer.SetPosition(i, new Vector3(p.x, 1, p.z));
}
}
Thanks in advance.