<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — How to add my Google Developers key?]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=914&amp;type=atom" />
	<updated>2018-10-17T06:08:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=914</id>
		<entry>
			<title type="html"><![CDATA[Re: How to add my Google Developers key?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4044#p4044" />
			<content type="html"><![CDATA[<p>Thank you very much Alex!</p><br /><p>Best regards,<br />Acacus</p>]]></content>
			<author>
				<name><![CDATA[Acacus]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=820</uri>
			</author>
			<updated>2018-10-17T06:08:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4044#p4044</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to add my Google Developers key?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4042#p4042" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Example:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class GoogleDirectionWithKeyExample: MonoBehaviour
{
    public string googleApiKey;
    public Vector2 origin;
    public Vector2 destination;

    private void Start()
    {
        OnlineMaps.instance.AddMarker(origin, &quot;Origin&quot;);
        OnlineMaps.instance.AddMarker(destination, &quot;Destination&quot;);

        // Begin to search a route from Los Angeles to the specified coordinates.
        OnlineMapsGoogleDirections request = OnlineMapsGoogleDirections.Find(
            new OnlineMapsGoogleDirections.Params(
                origin, destination)
            {
                key = googleApiKey,
                /*waypoints = new Vector2[]
                {
                    new Vector2( (float)point1.long, (float)point1.lat ),
                    new Vector2( (float)point2.long, (float)point2.lat )
                }*/
            });

        // Specifies that search results must be sent to OnFindDirectionComplete.
        request.OnComplete += OnFindDirectionComplete;
    }

    private void OnFindDirectionComplete(string response)
    {
        // Get the resut object.
        OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

        // Check that the result is not null, and the number of routes is not zero.
        if (result == null || result.routes.Length == 0)
        {
            Debug.Log(&quot;Find direction failed&quot;);
            Debug.Log(response);
            return;
        }

        // Showing the console instructions for each step.
        foreach (OnlineMapsGoogleDirectionsResult.Leg leg in result.routes[0].legs)
        {
            foreach (OnlineMapsGoogleDirectionsResult.Step step in leg.steps)
            {
                Debug.Log(step.string_instructions);
            }
        }

        // Create a line, on the basis of points of the route.
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.green);

        // Draw the line route on the map.
        OnlineMaps.instance.AddDrawingElement(route);
    }
}</code></pre></div><p>P.S. Most likely today a new version will be available through the built-in update system.<br />It has Key Manager. Specifying a key (for any service) once all your requests will automatically use it.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-10-16T13:22:36Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4042#p4042</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to add my Google Developers key?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4041#p4041" />
			<content type="html"><![CDATA[<p>Hello,</p><p>I&#039;m using OnlineMapsGoogleDirections.Find to find a route between two locations.<br />But it seems I reached the rate-limit and started to receive this message:</p><p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />&lt;DirectionsResponse&gt;<br /> &lt;status&gt;OVER_QUERY_LIMIT&lt;/status&gt;<br /> &lt;error_message&gt;You have exceeded your rate-limit for this API. We recommend registering for a key at the Google Developers Console: <a href="https://console.developers.google.com/apis/credentials?project=_&lt;/error_message&gt;">https://console.developers.google.com/a … essage&gt;</a><br />&lt;/DirectionsResponse&gt;</p><br /><p>I already have a Google Developers key but I have no idea where should I add it. can you help me with this please?</p><br /><p>Another question please:<br />According to the documentation; I can pass multiple waypoints to the previous function:</p><p>&quot;Google Direction - is a service that calculates directions between locations. You can search for directions for several modes of transportation, include transit, driving, walking or cycling. Directions may specify origins, destinations and waypoints either as text strings (e.g. &quot;Chicago, IL&quot; or &quot;Darwin, NT, Australia&quot;) or as latitude/longitude coordinates. The Directions API can return multi-part directions using a series of waypoints.&quot;</p><p>So can I do something like this?<br />OnlineMapsGoogleDirections query = OnlineMapsGoogleDirections.Find(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Vector2( (float)point0.long, (float)point0.lat ), <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Vector2( (float)point1.long, (float)point1.lat ),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Vector2( (float)point2.long, (float)point2.lat ),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Vector2( (float)point3.long, (float)point3.lat ),<br /> );</p><br /><p>Many thanks,</p>]]></content>
			<author>
				<name><![CDATA[Acacus]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=820</uri>
			</author>
			<updated>2018-10-16T12:51:06Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4041#p4041</id>
		</entry>
</feed>
