/// <summary> /// Coroutine that does the actual flyby logic. /// </summary> /// <param name="delay">delay between each location, in seconds.</param> /// <remarks> /// This logic is in a coroutine so that we don't have to put it in Update; /// Coroutines provide an easy way to keep track of time past /// </remarks> IEnumerator FlybyCoroutine(float delay) { // wait for delay, if there's any if (delay > 0) { yield return(new WaitForSecondsRealtime(delay)); } IsDoingFlyby = true; while (true) { foreach (var l in locations) { // calculate distance manually because we want to fly nearer Vector3 northeast = MapCamera.LatLongToUnity(l.viewport.northeast), southwest = MapCamera.LatLongToUnity(l.viewport.southwest); float diag = (northeast - southwest).magnitude; // viewport diagonal distance float dist = Mathf.Clamp(diag / 2f, 0.5f, camera.maxDistance); camera.SetCameraViewport(l, dist, true); camera.TargetElevation = 30f; // nice angle // wait for delay to fly to next location yield return(new WaitForSecondsRealtime(flybyInterval)); } } }
public MapTag ShowPlaceOnMap(Coords location, string name, Color?color = null) { if (location == null || name == null) { return(null); } Vector3 pos = MapCamera.LatLongToUnity(location); MapTag tag = Instantiate(tagPrefab, tagsHolder).GetComponent <MapTag>(); tag.transform.position = pos; tag.placeName.text = name; tag.placeName.color = color.HasValue ? color.Value : tag.placeName.color; tags.Add(tag); return(tag); }
public MapTag ShowPlaceOnMap(PlaceDetails place, Color?color = null) { if (place?.result?.geometry == null || place?.result?.name == null) { return(null); } Vector3 pos = MapCamera.LatLongToUnity(place.result.geometry.location); MapTag tag = Instantiate(tagPrefab, tagsHolder).GetComponent <MapTag>(); tag.transform.position = pos; tag.placeName.text = place.result.name; tag.placeName.color = color.HasValue ? color.Value : tag.placeName.color; tag.place = place; tags.Add(tag); return(tag); }
IEnumerator GetPlaceCoroutine(string place_id) { if (place_id == "") { yield break; } // do we need to retrieve Place Details? if (data.placeDetails == null || place_id != data.placeDetails.result.place_id) { WWW www = new WWW(PHPProxy.Escape(PlaceDetails.BuildURL(place_id, PlaceDetails.Fields.name | PlaceDetails.Fields.geometry | PlaceDetails.Fields.photo | PlaceDetails.Fields.place_id))); yield return(www); if (www.error != null) { Debug.Log(www.error); yield break; } data.placeDetails = JsonUtility.FromJson <PlaceDetails>(www.text); } if (data.placeDetails.status != "OK") { Debug.Log(data.placeDetails.error_message); yield break; } nameLabel.text = gameObject.name = data.placeDetails.result.name; yield return(GetTravelTimes()); data.pos = MapCamera.LatLongToUnity(data.placeDetails.result.geometry.location); // create a map tag on the world map mapTag = MapTagManager.Instance.ShowPlaceOnMap(data.placeDetails); IsLoading = false; // done with loading }