<?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 — Multiple marker followup]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1709</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1709&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Multiple marker followup.]]></description>
		<lastBuildDate>Fri, 05 Mar 2021 05:35:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Multiple marker followup]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7216#p7216</link>
			<description><![CDATA[<p>Thx. I will try that.</p>]]></description>
			<author><![CDATA[null@example.com (wuchi)]]></author>
			<pubDate>Fri, 05 Mar 2021 05:35:53 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7216#p7216</guid>
		</item>
		<item>
			<title><![CDATA[Re: Multiple marker followup]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7211#p7211</link>
			<description><![CDATA[<p>Hello.</p><p>How to center on the nearest marker:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class CenterOnNearestMarker : MonoBehaviour
{
    private void Center()
    {

        Vector2 position = OnlineMapsLocationService.instance.position;
        float bestSqrDistance = float.MaxValue;
        int bestIndex = -1;

        for (int i = 0; i &lt; OnlineMapsMarkerManager.instance.Count; i++)
        {
            OnlineMapsMarker marker = OnlineMapsMarkerManager.instance[i];
            Vector2 markerPosition = marker.position;
            float sqrDistance = (markerPosition - position).sqrMagnitude;
            if (sqrDistance &lt; bestSqrDistance)
            {
                bestSqrDistance = sqrDistance;
                bestIndex = i;
            }
        }

        if (bestIndex != -1)
        {
            OnlineMaps.instance.position = OnlineMapsMarkerManager.instance[bestIndex].position;
        }
    }

    private void OnGUI()
    {
        if (GUILayout.Button(&quot;Center&quot;)) Center();
    }
}</code></pre></div><p>Do you mean the route or just a line?<br />If you mean a line, then you can do it in this way:<br /></p><div class="codebox"><pre><code>using System.Linq;
using UnityEngine;

public class DrawLineByMarkers : MonoBehaviour
{
    private void Start()
    {
        OnlineMapsDrawingLine line = new OnlineMapsDrawingLine(OnlineMapsMarkerManager.instance.items.Select(m =&gt; m.position).ToArray(), Color.red, 5);
        line.followRelief = true;
        OnlineMapsDrawingElementManager.AddItem(line);
    }
}</code></pre></div><p>If you mean the route, then you need to make a request to some routing service (for example, Google Directions API).<br />Examples how to make a request and process the response is in the atlas of examples.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 04 Mar 2021 12:52:49 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7211#p7211</guid>
		</item>
		<item>
			<title><![CDATA[Multiple marker followup]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7209#p7209</link>
			<description><![CDATA[<p>Hello,</p><p>I am new here on the forum and i just bought the asset.</p><p>I know how to create multiple markers. I have a question is there possible to create and focus on marker that is closer to GPS data. For example i need this map for a treasure hunt game to show the people where they need to go next.</p><p>Also how to draw a route between 17 markers on the map to show complete map.</p><p>Thank you in advance for your answer.</p><p>Best regards,</p><p>Wuchi</p>]]></description>
			<author><![CDATA[null@example.com (wuchi)]]></author>
			<pubDate>Thu, 04 Mar 2021 04:45:38 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7209#p7209</guid>
		</item>
	</channel>
</rss>
