<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Google Places Autocomplete returns last value]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=755&amp;type=atom" />
	<updated>2018-01-24T17:07:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=755</id>
		<entry>
			<title type="html"><![CDATA[Re: Google Places Autocomplete returns last value]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3270#p3270" />
			<content type="html"><![CDATA[<p>It needs to be tested.<br />If you send your scene as a package to support (support@infinity-code.com) I&#039;ll check it and say you exactly what&#039;s wrong.<br />Otherwise, you need to test it yourself.<br />Add Log into each method, and make sure everything works as planned.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-01-24T17:07:28Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3270#p3270</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Google Places Autocomplete returns last value]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3268#p3268" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>Hello.</p><p>In your code, I see how you create instances for the result of the current request. <br />But where do you destroy the instances of the previous request?</p></blockquote></div><br /><p>I have that in other script:</p><div class="codebox"><pre><code> public void RemoveOldSearches()
    {
        InputSearchPlaceText.text = &quot;&quot;; 

        foreach (Transform child in ContentTransform.transform)
        {
            Destroy(child.gameObject);
        }

    }</code></pre></div><br /><p>and a in other script in a void update:</p><div class="codebox"><pre><code>      if (InputSearchPlaceText.text == &quot;&quot;) //Se o utilizador apagar a string toda entao apaga todos os butoes do searchPanel
        {
            foreach (Transform child in ContentTransform.transform)  //destroi todos os clones dos butoes da search antiga
            {
                Destroy(child.gameObject);
            }
        }</code></pre></div><p>What do you think is happening?</p>]]></content>
			<author>
				<name><![CDATA[geral]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=620</uri>
			</author>
			<updated>2018-01-24T14:36:21Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3268#p3268</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Google Places Autocomplete returns last value]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3262#p3262" />
			<content type="html"><![CDATA[<p>Hello.</p><p>In your code, I see how you create instances for the result of the current request. <br />But where do you destroy the instances of the previous request?</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-01-24T12:48:11Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3262#p3262</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Google Places Autocomplete returns last value]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3260#p3260" />
			<content type="html"><![CDATA[<p>Hi</p><p>I&#039;m using the AutocompleteApi from google,example from Atlas of examples.</p><p>The problem is that when i search a place, it always returns the last placa i searched, even after restarting editor in play mode.</p><p>This is the code i&#039;m using based on the example:</p><div class="codebox"><pre><code>public class AutocompleteAPIsearch : MonoBehaviour
{
    /// &lt;summary&gt;
    /// Google API Key
    /// &lt;/summary&gt;
    public string apiKey;
    private string placestring, types, language, components;
    Vector2 lnglat;
    int offset, radius;

    public InputField inputfield;

    public GameObject placeButton, transformada;

    OnlineMapsGooglePlacesAutocompleteResult[] results;

    public void autocomplete()
    {



        placestring = inputfield.text;
        offset = -1;
        types = null;
        lnglat = default(Vector2);
        radius = -1;

        if (LeanLocalization.CurrentLanguage == &quot;Portuguese&quot;) language = &quot;pt&quot;;
        if (LeanLocalization.CurrentLanguage == &quot;English&quot;) language = &quot;en&quot;;


        components = &quot;country:&quot; + language;
        Debug.Log(components);

        //lnglat = new Vector2(OnlineMapsLocationService.instance.position.x, OnlineMapsLocationService.instance.position.y);

        // Makes a request to Google Places Autocomplete API. See the reference in OnlineMaps Api Reference
        OnlineMapsGooglePlacesAutocomplete.Find(
            placestring,
            apiKey,
            types,
            offset,
           lnglat,
            radius,
            language,
            components
            ).OnComplete += OnComplete;
    }

    /// &lt;summary&gt;
    /// This method is called when a response is received.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;s&quot;&gt;Response string&lt;/param&gt;
    private void OnComplete(string s)
    {
        // Trying to get an array of results.
        results = OnlineMapsGooglePlacesAutocomplete.GetResults(s);

        //results = results.Distinct().ToArray();
        // If there is no result
        if (results == null)
        {
            Debug.Log(&quot;Error&quot;);
            Debug.Log(s);
            return;
        }
        else
        {

            // Log description of each result.
            // foreach (OnlineMapsGooglePlacesAutocompleteResult result in results)
            for (int i = 0; i &lt; results.Length; i++)
            {
                Instantiate(placeButton, transformada.transform);

                placeButton.GetComponentInChildren&lt;Text&gt;().text = results[i].description;

                Debug.Log(results[i].description);
            }

        }
    }</code></pre></div><br /><p>I always get the last place, but the strangest thing is that in the debug console, the name of the place is correct, and doesnt show the last place name.</p>]]></content>
			<author>
				<name><![CDATA[geral]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=620</uri>
			</author>
			<updated>2018-01-23T22:28:51Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3260#p3260</id>
		</entry>
</feed>
