示例#1
0
 private void Start()
 {
     OnlineMapsFindAutocomplete.Find(
         "Los ang",
         "" // <----------------------------- Google API Key
         ).OnComplete += OnComplete;
 }
 private void Start()
 {
     // Makes a request to Google Places Autocomplete API.
     OnlineMapsFindAutocomplete.Find(
         "Los ang",
         "" // <----------------------------- Google API Key
         ).OnComplete += OnComplete;
 }
示例#3
0
 private void OnComplete(string s)
 {
     OnlineMapsFindAutocompleteResult[] results = OnlineMapsFindAutocomplete.GetResults(s);
     if (results == null)
     {
         Debug.Log("Error");
         Debug.Log(s);
         return;
     }
     foreach (OnlineMapsFindAutocompleteResult result in results)
     {
         Debug.Log(result.description);
     }
 }
 /// <summary>
 /// Creates a new request to the Google Maps Place Autocomplete API.
 /// </summary>
 /// <param name="input">
 /// The text string on which to search. \n
 /// The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance.
 /// </param>
 /// <param name="key">
 /// Your application's API key. This key identifies your application for purposes of quota management. \n
 /// Visit the Google APIs Console to select an API Project and obtain your key. 
 /// </param>
 /// <param name="types">The types of place results to return.</param>
 /// <param name="offset">
 /// The position, in the input term, of the last character that the service uses to match predictions. \n
 /// For example, if the input is 'Google' and the offset is 3, the service will match on 'Goo'. \n
 /// The string determined by the offset is matched against the first word in the input term only. \n
 /// For example, if the input term is 'Google abc' and the offset is 3, the service will attempt to match against 'Goo abc'. \n
 /// If no offset is supplied, the service will use the whole term. \n
 /// The offset should generally be set to the position of the text caret.
 /// </param>
 /// <param name="latlng">The point around which you wish to retrieve place information.</param>
 /// <param name="radius">
 /// The distance (in meters) within which to return place results. \n
 /// Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.
 /// </param>
 /// <param name="language">The language in which to return results.</param>
 /// <param name="components">
 /// A grouping of places to which you would like to restrict your results. \n
 /// Currently, you can use components to filter by country. \n
 /// The country must be passed as a two character, ISO 3166-1 Alpha-2 compatible country code. \n
 /// For example: components=country:fr would restrict your results to places within France.
 /// </param>
 /// <returns>Query instance to the Google API.</returns>
 public static OnlineMapsFindAutocomplete Find(string input, string key, string types = null, int offset = -1, Vector2 latlng = default(Vector2), int radius = -1, string language = null, string components = null)
 {
     OnlineMapsFindAutocomplete query = new OnlineMapsFindAutocomplete(
         input,
         key,
         types,
         offset,
         latlng, 
         radius, 
         language, 
         components);
     OnlineMaps.instance.AddGoogleAPIQuery(query);
     return query;
 }
    /// <summary>
    /// Creates a new request to the Google Maps Place Autocomplete API.
    /// </summary>
    /// <param name="input">
    /// The text string on which to search. \n
    /// The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance.
    /// </param>
    /// <param name="key">
    /// Your application's API key. This key identifies your application for purposes of quota management. \n
    /// Visit the Google APIs Console to select an API Project and obtain your key.
    /// </param>
    /// <param name="types">The types of place results to return.</param>
    /// <param name="offset">
    /// The position, in the input term, of the last character that the service uses to match predictions. \n
    /// For example, if the input is 'Google' and the offset is 3, the service will match on 'Goo'. \n
    /// The string determined by the offset is matched against the first word in the input term only. \n
    /// For example, if the input term is 'Google abc' and the offset is 3, the service will attempt to match against 'Goo abc'. \n
    /// If no offset is supplied, the service will use the whole term. \n
    /// The offset should generally be set to the position of the text caret.
    /// </param>
    /// <param name="latlng">The point around which you wish to retrieve place information.</param>
    /// <param name="radius">
    /// The distance (in meters) within which to return place results. \n
    /// Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.
    /// </param>
    /// <param name="language">The language in which to return results.</param>
    /// <param name="components">
    /// A grouping of places to which you would like to restrict your results. \n
    /// Currently, you can use components to filter by country. \n
    /// The country must be passed as a two character, ISO 3166-1 Alpha-2 compatible country code. \n
    /// For example: components=country:fr would restrict your results to places within France.
    /// </param>
    /// <returns>Query instance to the Google API.</returns>
    public static OnlineMapsFindAutocomplete Find(string input, string key, string types = null, int offset = -1, Vector2 latlng = default(Vector2), int radius = -1, string language = null, string components = null)
    {
        OnlineMapsFindAutocomplete query = new OnlineMapsFindAutocomplete(
            input,
            key,
            types,
            offset,
            latlng,
            radius,
            language,
            components);

        OnlineMaps.instance.AddGoogleAPIQuery(query);
        return(query);
    }
        /// <summary>
        /// This method is called when a response is received.
        /// </summary>
        /// <param name="s">Response string</param>
        private void OnComplete(string s)
        {
            // Trying to get an array of results.
            OnlineMapsFindAutocompleteResult[] results = OnlineMapsFindAutocomplete.GetResults(s);

            // If there is no result
            if (results == null)
            {
                Debug.Log("Error");
                Debug.Log(s);
                return;
            }

            // Log description of each result.
            foreach (OnlineMapsFindAutocompleteResult result in results)
            {
                Debug.Log(result.description);
            }
        }