private void Awake() { _button = GetComponent <Button>(); _button.onClick.AddListener(HandleUserInput); _resource = new ForwardGeocodeResource(""); _camera = Camera.main; }
void Awake() { _inputField = GetComponent <InputField>(); _inputField.onEndEdit.AddListener(HandleUserInput); _resource = new ForwardGeocodeResource(""); _resource.Autocomplete = true; _resource.Country = countries; }
public void ForwardGeocoder() { var input = this.GetComponent <InputField>(); var forwardGeocode = new ForwardGeocodeResource(input.text); var slippy = GameObject.Find("Slippy").GetComponent <Slippy>(); fs.AccessToken = slippy.Token; geocoder.Geocode(forwardGeocode, (ForwardGeocodeResponse res) => { if (res.Features.Count > 0) { slippy.SetCenter(res.Features[0].Center); } }); }
public string GetCountryFromPlace(string toSearch) { string country = ""; fgr = new ForwardGeocodeResource(toSearch) { }; string locationUrl = fgr.GetUrl(); Debug.Log("url = " + locationUrl); var jsonLocationData = new WebClient().DownloadString(locationUrl); MyResult myResult = JsonUtility.FromJson <MyResult>(jsonLocationData); string[] tt = myResult.features[0].place_name.Split(','); country = tt.Last(); return(country); }
// --- public static IPromise <LatLong> GetLatLongForAddress(string streetAddress, string city, string country) { // Get access singleton (object that holds a token and associated geocoder). MapboxAccess access = MapboxAccess.Instance; Geocoder geocoder = access.Geocoder; var promise = new Promise <LatLong>(); string forwardGeocodeQuery = $"{streetAddress} {city} {country}"; Debug.Log($"Performing forward geocode with query \"{forwardGeocodeQuery}\""); ForwardGeocodeResource forwardGeocode = new ForwardGeocodeResource(forwardGeocodeQuery); geocoder.Geocode(forwardGeocode, (ForwardGeocodeResponse response) => { /* * Debug.Log($"Forward geocode response has features:"); * foreach (Feature feature in response.Features) { * Debug.Log($" - {feature.Id} {feature.PlaceName} {feature.Address} {feature.Center}"); * } */ // There are lots of interesting types of features returned by the API, places, POIs, localities, etc. // I'm assuming they're ordered by relevance, so let's just pick the first one. if (response.Features.Count > 0) { Feature chosenFeature = response.Features[0]; Vector2d coordinates = chosenFeature.Center; promise.Resolve(new LatLong((float)coordinates.x, (float)coordinates.y)); } else { promise.Resolve(new LatLong()); } }); return(promise); }
void OnEnable() { _resource = new ForwardGeocodeResource(""); EditorApplication.playModeStateChanged += OnModeChanged; }
void Awake() { _inputField = GetComponent <InputField>(); _inputField.onEndEdit.AddListener(HandleUserInput); _resource = new ForwardGeocodeResource(""); }
void Awake() { _resource = new ForwardGeocodeResource(""); }
void OnEnable() { _resource = new ForwardGeocodeResource(""); }