Esempio n. 1
0
        public void SearchAddress()
        {
            addressMenu.SetActive(false);
            string completeUrl;

            if (goMap.mapType == GOMap.GOMapType.Mapzen_Legacy)
            {
                string baseUrl = "https://search.mapzen.com/v1/search?";
                string apiKey  = goMap.mapzen_legacy_api_key;
                string text    = inputField.text;
                completeUrl = baseUrl + "&text=" + WWW.EscapeURL(text) + "&api_key=" + apiKey;
            }
            else
            {
                string baseUrl = "https://api.mapbox.com/geocoding/v5/mapbox.places/";
                string apiKey  = goMap.mapbox_accessToken;
                string text    = inputField.text;
                completeUrl = baseUrl + WWW.EscapeURL(text) + ".json" + "?access_token=" + apiKey;

                if (goMap.locationManager.currentLocation != null)
                {
                    completeUrl += "&proximity=" + goMap.locationManager.currentLocation.longitude + "%2C" + goMap.locationManager.currentLocation.latitude;
                }
                else if (goMap.locationManager.worldOrigin != null)
                {
                    completeUrl += "&proximity=" + goMap.locationManager.worldOrigin.longitude + "%2C" + goMap.locationManager.worldOrigin.latitude;
                }
            }
            Debug.Log(completeUrl);

            IEnumerator request = GOUrlRequest.jsonRequest(this, completeUrl, false, null, (Dictionary <string, object> response, string error) => {
                if (string.IsNullOrEmpty(error))
                {
                    IList features = (IList)response["features"];
                    LoadChoices(features);
                }
            });

            StartCoroutine(request);
        }