IEnumerator SearchLocation(string location) { double lat; double lng; location = location.Replace(" ", "+"); // this wont work anymore string url = "https://maps.googleapis.com/maps/api/streetview/metadata?location=" + location + "&key="; using (WWW www = new WWW(url)) { yield return(www); if (www.error == null) { SearchObject searchObject = JsonConvert.DeserializeObject <SearchObject>(www.text); if (object.Equals(searchObject.status, "OK")) { lat = searchObject.location.lat; lng = searchObject.location.lng; url = "https://cbks0.google.com/cbk?cb_client=apiv3&authuser=0&hl=en&output=polygon&it=1%3A1&rank=closest&ll=" + lat + "," + lng + "&radius=50"; using (WWW www2 = new WWW(url)) { yield return(www2); if (www.error == null) { PanoObject panoObject = JsonConvert.DeserializeObject <PanoObject>(www2.text); if (panoObject.result[0].id != null) { PanoID.SetPanoID(panoObject.result[0].id); SceneManager.LoadScene(1); } } else { Debug.Log("ERROR: " + www.error); } } } } else { Debug.Log("ERROR: " + www.error); } } }
IEnumerator SearchLocation() { double lat; double lng; string location = Input.Replace(" ", "+"); string url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + location + "&sensor=false&key=AIzaSyAr511nsGmQKDgZA-qmBVwXObp1m2KoDAo"; using (WWW www = new WWW(url)) { yield return(www); if (www.error == null) { SearchObject searchObject = JsonConvert.DeserializeObject <SearchObject>(www.text); if (object.Equals(searchObject.status, "OK")) { lat = searchObject.results[0].geometry.location.lat; lng = searchObject.results[0].geometry.location.lng; url = "https://cbks0.google.com/cbk?cb_client=apiv3&authuser=0&hl=en&output=polygon&it=1%3A1&rank=closest&ll=" + lat + "," + lng + "&radius=500"; using (WWW www2 = new WWW(url)) { yield return(www2); if (www.error == null) { PanoObject panoObject = JsonConvert.DeserializeObject <PanoObject>(www2.text); if (panoObject.result[0].id != null) { PanoID.SetPanoID(panoObject.result[0].id); SceneManager.LoadScene(1); } } else { Debug.Log("ERROR: " + www.error); } } } } else { Debug.Log("ERROR: " + www.error); } } }
IEnumerator Start() { Application.lowMemory += OnLowMemory; // The number of tiles changes with zoom level (zoom=4, x=12, y=6. zoom=5, x=25, y=12) // Dimensions of final image depend on zoom as well, (416 * 2^zoom)x(416 * 2^(zoom - 1)) (??????) panoWidth = tilex * tileDim; panoHeight = tiley * tileDim - 256; panoTex = new Texture2D(panoWidth, panoHeight, TextureFormat.RGB24, false); // Starts a new coroutine to get each tile in the equirectangular image (width=26 tiles, height=13 tiles). for (int i = 0; i < tiley; i++) { for (int j = 0; j < tilex; j++) { // Limits the number of running coroutines to 50. If the limit is reached, wait for 1 second. // This prevents running out of memory when textures are being created. if (runningCoroutines > 30) { yield return(new WaitUntil(() => runningCoroutines < 30)); } // Url containing the tiles. // PanoID is for the panorama of selected streetview location (this cannot be changed yet, but can be later once navigation is implemented). string url = "https://cbk0.google.com/cbk?output=tile&panoid=" + PanoID.GetPanoID() + "&zoom=" + zoom + "&x=" + j + "&y=" + i; StartCoroutine(GetTexture(url, j, i)); runningCoroutines++; } } yield return(null); }