<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Draw custom routes]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=939&amp;type=atom" />
	<updated>2018-11-08T14:29:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=939</id>
		<entry>
			<title type="html"><![CDATA[Re: Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4186#p4186" />
			<content type="html"><![CDATA[<p>HERE Routing API:<br /><a href="http://infinity-code.com/atlas/online-maps/pages/HereRoutingAPIExample.html">http://infinity-code.com/atlas/online-m … ample.html</a></p><p>Open Route Service:<br /><a href="http://infinity-code.com/atlas/online-maps/pages/OpenRouteServiceExample.html">http://infinity-code.com/atlas/online-m … ample.html</a></p><p>If you know another good service for finding routes, please let me know. <br />But this service should be completely free, or have a some free quota.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-11-08T14:29:52Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4186#p4186</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4185#p4185" />
			<content type="html"><![CDATA[<p>Is there any other way to draw roads, so without Google API?</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-11-08T14:25:02Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4185#p4185</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4183#p4183" />
			<content type="html"><![CDATA[<p>Please make sure that you have Online Maps Key Manager component, and entered your Google API key.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-11-08T12:58:07Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4183#p4183</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4182#p4182" />
			<content type="html"><![CDATA[<p>Thankyou for your answer. It is not drawing a road but it is detecting the mouse clicks. Could you maybe send me an example scene? Or what source, provider and type do you use? I feel like I am missing something, either the result turns out null or the routes length is null.</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-11-08T12:24:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4182#p4182</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4181#p4181" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Here is an example of how to find a route between clicks.<br />I minimized the code as possible so that you can more easily understand how it works.</p><div class="codebox"><pre><code>using UnityEngine;

public class DrawRouteOnClick:MonoBehaviour
{
    private int clickIndex = 0;
    private Vector2[] clicks = new Vector2[2];

    private void Start()
    {
        // Subscribe to click event
        OnlineMapsControlBase.instance.OnMapClick += OnMapClick;
    }

    private void OnMapClick()
    {
        // Store coordinates of clicks (0 - start, 1 - finish)
        clicks[clickIndex] = OnlineMapsControlBase.instance.GetCoords();
        clickIndex++;

        // If count points == 2
        if (clickIndex == 2)
        {
            // Find a route and subscribe to complete event
            OnlineMapsGoogleDirections.Find(clicks[0], clicks[1]).OnComplete += OnGoogleDirectionsComplete;

            // Reset click index
            clickIndex = 0;
        }
    }

    private void OnGoogleDirectionsComplete(string response)
    {
        // Remove previous routes
        OnlineMaps.instance.RemoveAllDrawingElements();

        // Load result object from response string
        OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

        // If something wrong, then return
        if (result == null || result.routes.Length == 0) return;

        // Create a route line
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.red, 3);

        // Add a line to the map
        OnlineMaps.instance.AddDrawingElement(route);
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-11-08T11:43:36Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4181#p4181</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Draw custom routes]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4179#p4179" />
			<content type="html"><![CDATA[<p>Hi,</p><p>I have found the examples of how to draw routes between certain points in the Atlas, but I can&#039;t get them working in my scene (could be that I am using the wrong settings). Is there maybe a simple way to draw your own custom routes just with some mouseclicks? </p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-11-08T10:11:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4179#p4179</id>
		</entry>
</feed>
