private void OnComplete(string response) { OnlineMaps.instance.RemoveMarkerAt(0); OnlineMaps.instance.RemoveAllDrawingElements(); OnlineMapsFindDirection.Find(fromPlace, toPlace).OnComplete -= OnComplete; List <OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response); if (steps == null) { Debug.Log("Something wrong"); Debug.Log(response); return; } // Create a new marker in first point. marker = OnlineMaps.instance.AddMarker(steps[0].start, "XAD"); // Gets points of route. points = OnlineMapsDirectionStep.GetPoints(steps); // Draw the route. OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 1); OnlineMaps.instance.AddDrawingElement(route); OnlineMaps.instance.position = marker.position; OnlineMaps.instance.Redraw(); pointIndex = 0; }
public Leg(OnlineMapsXML node) { List <Step> steps = new List <Step>(); foreach (OnlineMapsXML n in node) { if (n.name == "step") { steps.Add(new Step(n)); } else if (n.name == "duration") { duration = new TextValue <int>(n); } else if (n.name == "duration_in_traffic") { duration_in_traffic = new TextValue <int>(n); } else if (n.name == "distance") { distance = new TextValue <int>(n); } else if (n.name == "start_location") { start_location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "end_location") { end_location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "start_address") { start_address = n.Value(); } else if (n.name == "end_address") { end_address = n.Value(); } else if (n.name == "via_waypoint") { via_waypoint = new ViaWaypoint(n); } else if (n.name == "arrival_time") { arrival_time = new TextValueZone <string>(n); } else if (n.name == "departure_time") { departure_time = new TextValueZone <string>(n); } else { Debug.Log("Leg: " + n.name + "\n" + n.outerXml); } } this.steps = steps.ToArray(); }
private void Start() { // Begin to search a route from Los Angeles to the specified coordinates. OnlineMapsGoogleAPIQuery query = OnlineMapsFindDirection.Find("Los Angeles", new Vector2(-118.178960f, 35.063995f)); // Specifies that search results must be sent to OnFindDirectionComplete. query.OnComplete += OnFindDirectionComplete; }
public Route(OnlineMapsXML node) { List <Leg> legs = new List <Leg>(); List <int> waypointOrder = new List <int>(); List <string> warnings = new List <string>(); foreach (OnlineMapsXML n in node) { if (n.name == "summary") { summary = n.Value(); } else if (n.name == "leg") { legs.Add(new Leg(n)); } else if (n.name == "copyrights") { copyrights = n.Value(); } else if (n.name == "overview_polyline") { overview_polyline = OnlineMapsFindDirection.DecodePolylinePoints(n["points"].Value()).ToArray(); } else if (n.name == "waypoint_index") { waypointOrder.Add(n.Value <int>()); } else if (n.name == "warning") { warnings.Add(n.Value()); } else if (n.name == "fare") { fare = new Fare(n); } else if (n.name == "bounds") { OnlineMapsXML sw = n["southwest"]; OnlineMapsXML ne = n["northeast"]; bounds = new OnlineMapsGPXObject.Bounds(sw.Get <double>("lng"), sw.Get <double>("lat"), ne.Get <double>("lng"), ne.Get <double>("lat")); } else { Debug.Log("Route: " + n.name + "\n" + n.outerXml); } } this.legs = legs.ToArray(); this.waypoint_order = waypointOrder.ToArray(); this.warnings = warnings.ToArray(); }
public NameLocation(OnlineMapsXML node) { foreach (OnlineMapsXML n in node) { if (n.name == "location") { location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "name") { name = n.Value(); } else { Debug.Log("NameLocation: " + n.name + "\n" + n.outerXml); } } }
public ViaWaypoint(OnlineMapsXML node) { foreach (OnlineMapsXML n in node) { if (n.name == "location") { location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "step_index") { step_index = n.Value <int>(); } else if (n.name == "step_interpolation") { step_interpolation = n.Value <double>(); } else { Debug.Log("ViaWaypoint: " + n.name + "\n" + n.outerXml); } } }
private void Start() { // Looking for a route between locations. OnlineMapsFindDirection.Find(fromPlace, toPlace).OnComplete += OnComplete; }
public void findpath(int id) { fromPlace = AppState.ProductAddress [(AppState.PRODUCTS)id].fromAddress; toPlace = AppState.ProductAddress [(AppState.PRODUCTS)id].toAddress; OnlineMapsFindDirection.Find(fromPlace, toPlace).OnComplete += OnComplete; }
/// <summary> /// Find route by coordinates or title. /// </summary> /// <param name="origin"> /// Coordinates or the name of the route begins. /// </param> /// <param name="destination"> /// Coordinates or the name of the route ends. /// </param> /// <returns> /// Query instance to the Google API. /// </returns> /// <remarks></remarks> /// <example> /// Example: /// <code> /// OnlineMapsFindDirection.Find("Los Angeles", new Vector2(-118.178960f, 35.063995f)).OnComplete += OnFindDirectionComplete; /// /// private void OnFindDirectionComplete(string response) /// { /// List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response); /// if (steps != null) /// { /// foreach (OnlineMapsDirectionStep step in steps) /// { /// Debug.Log(step.instructions); /// } /// /// List<Vector2> points = OnlineMapsDirectionStep.GetPoints(steps); /// Debug.Log(points.Count); /// } /// } /// </code> /// </example> public OnlineMapsGoogleAPIQuery FindDirection(string origin, string destination) { OnlineMapsFindDirection fl = new OnlineMapsFindDirection(origin, destination); googleQueries.Add(fl); return fl; }
public Step(OnlineMapsXML node) { List <Step> steps = new List <Step>(); foreach (OnlineMapsXML n in node) { if (n.name == "travel_mode") { travel_mode = n.Value(); } else if (n.name == "start_location") { start_location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "end_location") { end_location = OnlineMapsFindDirection.GetVector2FromNode(n); } else if (n.name == "polyline") { polyline = OnlineMapsFindDirection.DecodePolylinePoints(n["points"].Value()).ToArray(); } else if (n.name == "duration") { duration = new TextValue <int>(n); } else if (n.name == "distance") { distance = new TextValue <int>(n); } else if (n.name == "step") { steps.Add(new Step(n)); } else if (n.name == "html_instructions") { html_instructions = n.Value(); if (string.IsNullOrEmpty(html_instructions)) { return; } string_instructions = OnlineMapsDirectionStep.StrReplace(html_instructions, new[] { "<", ">", " ", "&", "&nbsp;" }, new[] { "<", ">", " ", "&", " " }); string_instructions = Regex.Replace(string_instructions, "<div.*?>", "\n"); string_instructions = Regex.Replace(string_instructions, "<.*?>", string.Empty); } else if (n.name == "maneuver") { maneuver = n.Value(); } else if (n.name == "transit_details") { transit_details = new TransitDetails(n); } else { Debug.Log("Step: " + n.name + "\n" + n.outerXml); } } this.steps = steps.ToArray(); }