<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — GPX Line car]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2110</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2110&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in GPX Line car.]]></description>
		<lastBuildDate>Sun, 23 Apr 2023 11:47:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9000#p9000</link>
			<description><![CDATA[<p>The code above does what you are asked about.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Sun, 23 Apr 2023 11:47:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9000#p9000</guid>
		</item>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8999#p8999</link>
			<description><![CDATA[<p>Thanks Alex for the example. I can get the distance with the slider value between two coordinates that I use as a test but how can I add an indicator ( game object ) that shows the position of the slider value on the map line (line render gpx) ?</p>]]></description>
			<author><![CDATA[null@example.com (LazzLab)]]></author>
			<pubDate>Sat, 22 Apr 2023 15:44:29 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8999#p8999</guid>
		</item>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8998#p8998</link>
			<description><![CDATA[<p>Thanks Alex.</p>]]></description>
			<author><![CDATA[null@example.com (LazzLab)]]></author>
			<pubDate>Fri, 21 Apr 2023 16:29:11 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8998#p8998</guid>
		</item>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8996#p8996</link>
			<description><![CDATA[<p>Sure, here&#039;s the code:<br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
/// Current progress value (0-1)
/// &lt;/summary&gt;
public float progress;
    
/// &lt;summary&gt;
/// Points of the route
/// &lt;/summary&gt;
private OnlineMapsVector2d[] points;

private void UpdateMarkerPosition()
{
    // Calculate the total distance of the route.
    double totalDistanceKm = 0;
    for (int i = 0; i &lt; points.Length - 1; i++)
    {
        OnlineMapsVector2d p1 = points[i];
        OnlineMapsVector2d p2 = points[i + 1];
        totalDistanceKm += OnlineMapsUtils.DistanceBetweenPoints(p1.x, p1.y, 0, p2.x, p2.y, 0);
    }
    
    // Calculate the distance covered.
    double coveredDistanceKm = totalDistanceKm * Mathf.Clamp01(progress);

    for (int i = 0; i &lt; points.Length - 1; i++)
    {
        // Calculate the distance between the current and next point.
        OnlineMapsVector2d p1 = points[i];
        OnlineMapsVector2d p2 = points[i + 1];
        double distance = OnlineMapsUtils.DistanceBetweenPoints(p1.x, p1.y, 0, p2.x, p2.y, 0);
        
        // If the distance covered is greater than the distance between the current and next point,
        // subtract the distance between the current and next point from the distance covered.
        if (coveredDistanceKm &gt; distance)
        {
            coveredDistanceKm -= distance;
        }
        // If the distance covered is less or equal than the distance between the current and next point,
        // calculate the position of the marker.
        else
        {
            double lng = p1.x + (p2.x - p1.x) * coveredDistanceKm / distance;
            double lat = p1.y + (p2.y - p1.y) * coveredDistanceKm / distance;
            marker.SetPosition(lng, lat);
            break;
        }
    }
}</code></pre></div><p>P.S. This is theoretical code and I have not tested it. I hope I wrote it without bugs.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 20 Apr 2023 14:58:09 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8996#p8996</guid>
		</item>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8995#p8995</link>
			<description><![CDATA[<p>Thanks Alex. Can you give me an example?</p>]]></description>
			<author><![CDATA[null@example.com (LazzLab)]]></author>
			<pubDate>Thu, 20 Apr 2023 14:43:50 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8995#p8995</guid>
		</item>
		<item>
			<title><![CDATA[Re: GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8987#p8987</link>
			<description><![CDATA[<p>Hi.</p><p>You need to calculate the total length of the route (add the lengths of all segments).<br />Based on the progress of your slider, the length of the route that the car has covered (total * progress).<br />Next, you need to find the segment (two points, AB, BC, CD, etc.) where the car is.<br />Go through all the segments of your route.<br />If the length of the segment is less than the covered length, subtract the length of the segment from the covered length.<br />If it is greater than or equal to, you have found the desired segment.<br />Next, you need to find a point on the segment.<br />This is very easy to do, just Lerp(a, b, coveredLength / segmentLength).</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 19 Apr 2023 19:54:25 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8987#p8987</guid>
		</item>
		<item>
			<title><![CDATA[GPX Line car]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8986#p8986</link>
			<description><![CDATA[<p>Hi Alex I hope all is well. I upload a GPX and redraw it with DrawingElement line on the 3d map. Everything OK. Request. How can I make a GameObject ( car ) move along the line with a ui slider ? Thank you</p>]]></description>
			<author><![CDATA[null@example.com (LazzLab)]]></author>
			<pubDate>Wed, 19 Apr 2023 09:44:21 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8986#p8986</guid>
		</item>
	</channel>
</rss>
