<?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 — Google maps API Key]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2056</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2056&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Google maps API Key.]]></description>
		<lastBuildDate>Fri, 11 Nov 2022 19:24:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Google maps API Key]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8723#p8723</link>
			<description><![CDATA[<p>First of all, you need to access the Tiles API.<br />When and if it&#039;s ready, you can use it this way:<br /></p><div class="codebox"><pre><code>using System.Collections;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;

namespace InfinityCode.OnlineMapsExamples
{
    public class GoogleTilesAPI : MonoBehaviour
    {
        public string apiKey;
        public string mapType = &quot;roadmap&quot;;
        public string language = &quot;ja-JP&quot;;
        public string region = &quot;region&quot;;
        public string[] layerTypes = { &quot;layerRoadmap&quot; };
        public bool overlay = false;
        public string scale = &quot;scaleFactor1x&quot;;

        private string url = &quot;https://www.googleapis.com/tile/v1/tiles/{zoom}/{x}/{y}?session={sessiontoken}&amp;key={apikey}&quot;;
        private string sessiontoken;

        private IEnumerator GetSessionToken()
        {
            OnlineMapsJSONObject jReq = new OnlineMapsJSONObject();
            jReq.Add(&quot;mapType&quot;, mapType);
            jReq.Add(&quot;language&quot;, language);
            jReq.Add(&quot;region&quot;, region);
            jReq.Add(&quot;overlay&quot;, overlay);
            jReq.Add(&quot;scale&quot;, scale);
            OnlineMapsJSONArray jLayers = new OnlineMapsJSONArray();
            foreach (string l in layerTypes)
            {
                jLayers.Add(new OnlineMapsJSONValue(l));
            }

            jReq.Add(&quot;layerTypes&quot;, jLayers);

            UnityWebRequest www = UnityWebRequest.Post(&quot;https://www.googleapis.com/tile/v1/createSession?key=&quot; + apiKey, jReq.ToString());
            yield return www.SendWebRequest();

            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.Log(www.error + &quot;\n&quot; + Encoding.UTF8.GetString(www.downloadHandler.data));
                yield break;
            }

            string response = Encoding.UTF8.GetString(www.downloadHandler.data);
            OnlineMapsJSONItem json = OnlineMapsJSON.Parse(response);
            sessiontoken = json.V&lt;string&gt;(&quot;session&quot;);

            OnlineMaps.instance.tileManager.tiles.ForEach(t =&gt;
            {
                if (t.status == OnlineMapsTileStatus.error) t.status = OnlineMapsTileStatus.none;
            });

            OnlineMaps.instance.Redraw();
        }

        private string OnReplaceUrlToken(OnlineMapsTile tile, string token)
        {
            if (token == &quot;sessiontoken&quot;) return sessiontoken;
            if (token == &quot;apikey&quot;) return apiKey;
            return null;
        }

        private void OnStartDownloadTile(OnlineMapsTile tile)
        {
            if (string.IsNullOrEmpty(sessiontoken))
            {
                tile.status = OnlineMapsTileStatus.error;
                return;
            }

            OnlineMapsTileManager.StartDownloadTile(tile);
        }

        private void Start()
        {
            OnlineMapsProvider.GetProviders().FirstOrDefault(p =&gt; p.id == &quot;google&quot;).AppendTypes(
                new OnlineMapsProvider.MapType(&quot;tilesapi&quot;) { urlWithLabels = url, }
            );

            OnlineMapsTile.OnReplaceURLToken += OnReplaceUrlToken;
            OnlineMapsTileManager.OnStartDownloadTile += OnStartDownloadTile;

            OnlineMaps.instance.mapType = &quot;google.tilesapi&quot;;

            StartCoroutine(GetSessionToken());
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 11 Nov 2022 19:24:53 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8723#p8723</guid>
		</item>
		<item>
			<title><![CDATA[Re: Google maps API Key]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8722#p8722</link>
			<description><![CDATA[<p>So, even though it&#039;s fine to use it like that, to be 100% legal and covered I should get a key and just add it to the key manager at the google map field? No more changes are needed correct?</p><p>Thanks for all your help and congrats on the amazing plugin you&#039;ve created!</p>]]></description>
			<author><![CDATA[null@example.com (InfoRun)]]></author>
			<pubDate>Fri, 11 Nov 2022 07:12:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8722#p8722</guid>
		</item>
		<item>
			<title><![CDATA[Re: Google maps API Key]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8721#p8721</link>
			<description><![CDATA[<p>Hello.</p><p>This is the key for Google Web Services API (such as Geocoding API, Directions API, etc.), not tiles.<br />URL to the tiles, which is used in the preset for test purposes, does not use any key.</p><p>As written in Licenses and API keys section of the asset documentation:<br /></p><div class="quotebox"><blockquote><p>The legal way is to use Google Maps tiles in your applications:<br /><a href="https://developers.google.com/maps/documentation/tile/">https://developers.google.com/maps/documentation/tile/</a></p></blockquote></div><p>The test preset will work when the application goes live.<br />Use it, or the legal way, or change the tile provider, it&#039;s your choice.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 10 Nov 2022 15:57:05 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8721#p8721</guid>
		</item>
		<item>
			<title><![CDATA[Google maps API Key]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8720#p8720</link>
			<description><![CDATA[<p>Hello,</p><p>I am currently using the plugin and have created an online map using google maps as a provider. I have seen that even though in the key manager I have not input any keys for google maps, the map itself is working fine both in the editor and in the mobile devices both ios and android. </p><p>Is there something I am missing? How can the maps work without a key? I have uploaded the app on closed testing for now and it seems to be working there as well. Will the maps cease to function when the app goes live?</p><p>Thank you.</p>]]></description>
			<author><![CDATA[null@example.com (InfoRun)]]></author>
			<pubDate>Thu, 10 Nov 2022 10:22:30 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8720#p8720</guid>
		</item>
	</channel>
</rss>
