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 = OnlineMapsXML.GetVector2dFromNode(n);
                }
                else if (n.name == "end_location")
                {
                    end_location = OnlineMapsXML.GetVector2dFromNode(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();
        }
 public NameLocation(OnlineMapsXML node)
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "location")
         {
             location = OnlineMapsXML.GetVector2dFromNode(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 = OnlineMapsXML.GetVector2dFromNode(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);
         }
     }
 }
        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 = OnlineMapsXML.GetVector2dFromNode(n);
                }
                else if (n.name == "end_location")
                {
                    end_location = OnlineMapsXML.GetVector2dFromNode(n);
                }
                else if (n.name == "polyline")
                {
                    polylineD = OnlineMapsUtils.DecodePolylinePointsD(n["points"].Value()).ToArray();
                    polyline  = polylineD.Select(p => (Vector2)p).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[] { "&lt;", "&gt;", "&nbsp;", "&amp;", "&amp;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();
        }