<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Multiple marker followup]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1709&amp;type=atom" />
	<updated>2021-03-05T05:35:53Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1709</id>
		<entry>
			<title type="html"><![CDATA[Re: Multiple marker followup]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7216#p7216" />
			<content type="html"><![CDATA[<p>Thx. I will try that.</p>]]></content>
			<author>
				<name><![CDATA[wuchi]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1556</uri>
			</author>
			<updated>2021-03-05T05:35:53Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7216#p7216</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Multiple marker followup]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7211#p7211" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-03-04T12:52:49Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7211#p7211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Multiple marker followup]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7209#p7209" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[wuchi]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1556</uri>
			</author>
			<updated>2021-03-04T04:45:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7209#p7209</id>
		</entry>
</feed>
