public void CheckInTheCenter(Vector2 yourPos, int centerID) { OnlineMapsGoogleDirections query = OnlineMapsGoogleDirections.Find(yourPos, Datacenter.instance.listCenter[centerID].pos); query.OnComplete += CheckKC; }
private void OnMapClick() { control.GetCoords(out targetLng, out targetLat); if (targetMarker == null) { targetMarker = OnlineMapsMarker3DManager.CreateItem(targetLng, targetLat, targetPrefab); targetMarker.scale = targetScale; } else { targetMarker.SetPosition(targetLng, targetLat); } double tx1, ty1, tx2, ty2; map.projection.CoordinatesToTile(lng, lat, map.zoom, out tx1, out ty1); map.projection.CoordinatesToTile(targetLng, targetLat, map.zoom, out tx2, out ty2); rotation = (float)OnlineMapsUtils.Angle2D(tx1, ty1, tx2, ty2) - 90; if (!OnlineMapsKeyManager.hasGoogleMaps) { Debug.LogWarning("Please enter Map / Key Manager / Google Maps"); return; } OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(OnlineMapsKeyManager.GoogleMaps(), new Vector2((float)lng, (float)lat), control.GetCoords()); request.OnComplete += OnRequestComplete; request.Send(); }
void UpdateDistant(int i, Vector2 pos) { OnlineMapsGoogleDirections query = OnlineMapsGoogleDirections.Find(OnlineMapsLocationService.instance.position, Datacenter.instance.listCenter[i].pos); query.OnComplete += OnDistanFindComplete; }
/// <summary> /// This method is called when the response from Google Directions API is received /// </summary> /// <param name="response">Response from Google Direction API</param> private void OnGoogleDirectionsComplete(string response) { Debug.Log(response); // Try load result OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); if (result == null || result.routes.Length == 0) { return; } // Get the first route OnlineMapsGoogleDirectionsResult.Route route = result.routes[0]; // Draw route on the map OnlineMapsDrawingElementManager.AddItem(new OnlineMapsDrawingLine(route.overview_polyline, Color.red, 3)); // Calculate the distance int distance = route.legs.Sum(l => l.distance.value); // meters // Calculate the duration int duration = route.legs.Sum(l => l.duration.value); // seconds // Log distane and duration Debug.Log("Distance: " + distance + " meters, or " + (distance / 1000f).ToString("F2") + " km"); Debug.Log("Duration: " + duration + " sec, or " + (duration / 60f).ToString("F1") + " min, or " + (duration / 3600f).ToString("F1") + " hours"); }
private void OnComplete(string response) { Debug.Log("OnComplete"); OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); if (result == null || result.routes.Length == 0) { Debug.Log("Something wrong"); Debug.Log(response); return; } OnlineMapsGoogleDirectionsResult.Route firstRoute = result.routes[0]; List <OnlineMapsGoogleDirectionsResult.Step> steps = firstRoute.legs.SelectMany(l => l.steps).ToList(); // Create a new marker in first point. marker = OnlineMapsMarkerManager.CreateItem(steps[0].start_location, "Car"); // Gets points of route. points = firstRoute.overview_polylineD; // Draw the route. OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 3); OnlineMapsDrawingElementManager.AddItem(route); pointIndex = 0; }
private void OnFindDirectionComplete(string response) { // Get the resut object. OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); // Check that the result is not null, and the number of routes is not zero. if (result == null || result.routes.Length == 0) { Debug.Log("Find direction failed"); Debug.Log(response); return; } // Showing the console instructions for each step. foreach (OnlineMapsGoogleDirectionsResult.Leg leg in result.routes[0].legs) { foreach (OnlineMapsGoogleDirectionsResult.Step step in leg.steps) { Debug.Log(step.string_instructions); } } // Create a line, on the basis of points of the route. OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.green); // Draw the line route on the map. OnlineMaps.instance.AddDrawingElement(route); }
public void PrintTheRoute(string End) { OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections("AIzaSyDgAoQ2SBb8nvf3vtFC5UAqkA6WA1Xijho", OnlineMapsLocationService.instance.position, End); Debug.Log(request); request.OnComplete += OnRequestDone; request.Send(); }
private void Start() { if (string.IsNullOrEmpty(googleAPIKey)) Debug.LogWarning("Please specify Google API Key"); // Find route using Google Directions API OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(googleAPIKey, "Los Angeles", new Vector2(-118.178960f, 35.063995f)); request.OnComplete += OnGoogleDirectionsComplete; request.Send(); }
private void Start() { // Begin to search a route from Los Angeles to the specified coordinates. OnlineMapsGoogleDirections query = OnlineMapsGoogleDirections.Find("Los Angeles", new Vector2(-118.178960f, 35.063995f)); // Specifies that search results must be sent to OnFindDirectionComplete. query.OnComplete += OnFindDirectionComplete; }
private void Start() { if (string.IsNullOrEmpty(googleAPIKey)) { Debug.LogWarning("Please specify Google API Key"); } // Looking for a route between locations. OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(googleAPIKey, fromPlace, toPlace); request.OnComplete += OnComplete; request.Send(); }
public void OnDirectionGoogleButtonClick() { if (FromLocale.data == null || ToLocale.data == null) { return; } PopupManager.Instance.ShowLoading(); // Begin to search a route from Los Angeles to the specified coordinates. OnlineMapsGoogleDirections query = OnlineMapsGoogleDirections.Find(FromLocale.data.location, ToLocale.data.location); // Specifies that search results must be sent to OnFindDirectionComplete. query.OnComplete += OnFindDirectionGoogleComplete; }
private void OnRequestDone(string response) { Debug.Log(response); OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); if (result == null || result.routes.Length == 0) { return; } OnlineMapsDrawingElementManager.RemoveAllItems(); OnlineMapsGoogleDirectionsResult.Route route = result.routes[0]; OnlineMapsDrawingElementManager.AddItem(new OnlineMapsDrawingLine(route.overview_polyline, Color.blue, 3)); }
private void Start() { if (string.IsNullOrEmpty(googleAPIKey)) { Debug.LogWarning("Please specify Google API Key"); } // Begin to search a route from Los Angeles to the specified coordinates. OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections ( googleAPIKey, "Los Angeles", // FROM (string or Vector2) new Vector2(-118.178960f, 35.063995f) // TO (string or Vector2) ); // Specifies that search results must be sent to OnFindDirectionComplete. request.OnComplete += OnFindDirectionComplete; request.Send(); }
private void OnRequestComplete(string response) { OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); if (result == null || result.routes.Length == 0) { Debug.Log("No result"); return; } points = result.routes[0].overview_polylineD; if (route == null) { route = new OnlineMapsDrawingLine(points, Color.green, 3); OnlineMapsDrawingElementManager.AddItem(route); } else { route.points = points; } pointIndex = 0; }
private void Start() { // Find route using Google Directions API OnlineMapsGoogleDirections.Find("Los Angeles", new Vector2(-118.178960f, 35.063995f)).OnComplete += OnGoogleDirectionsComplete; }
public new static OnlineMapsFindDirectionResult GetResult(string response) { OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response); return(OnlineMapsUtils.DeepCopy <OnlineMapsFindDirectionResult>(result)); }
private void Start() { // Looking for a route between locations. OnlineMapsGoogleDirections.Find(fromPlace, toPlace).OnComplete += OnComplete; }