////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 20JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * default constructor.
  */
 public GoogleMapService()
 {
     _geocoder = new GClientGeocoder();
     _reverseGeocoder = new GReverseClientGeocoder();
     _directionQuery = new GDirections();
     _ipAddressGeocoder = new IpAddressGeocoder();
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 20JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * default constructor.
         */
        public GoogleMapService()
        {
            _geocoder          = new GClientGeocoder();
            _reverseGeocoder   = new GReverseClientGeocoder();
            _directionQuery    = new GDirections();
            _ipAddressGeocoder = new IpAddressGeocoder();
        }
Example #3
0
        public void GerarRota()
        {
            DatabaseContext DbGMap = new DatabaseContext();

            GMapOverlay.Markers.Clear();
            GMapOverlay.Routes.Clear();

            List <IPassageiro> ListaPassageiro = DbGMap.Passageiros.ToList();

            if (DbGMap.Fretamentos.Count() > 0)
            {
                foreach (IFretamento IFretamento in DbGMap.Fretamentos)
                {
                    List <PointLatLng> WAYPOINTS = new List <PointLatLng>();

                    Random RANDOM      = new Random();
                    Color  RAMDOMCOLOR = Color.FromArgb(RANDOM.Next(256), RANDOM.Next(256), RANDOM.Next(256));

                    GMarkerGoogle ORIGEM = new GMarkerGoogle(IFretamento.I5_ORG_COORDENADAS, GMarkerGoogleType.MARKER_BEGIN, RAMDOMCOLOR, string.Empty);
                    GMapOverlay.Markers.Add(ORIGEM);
                    WAYPOINTS.Add(ORIGEM.Position);

                    if (!string.IsNullOrEmpty(IFretamento.I5_PASSAGEIROS))
                    {
                        foreach (IPassageiro IPassageiro in ListaPassageiro.Where(x => IFretamento.I5_PASSAGEIROS.Contains(x.I0_ID.ToString().PadLeft(6, '0'))))
                        {
                            GMarkerGoogle WAYPOINT = new GMarkerGoogle(IPassageiro.I0_COORDENADAS, GMarkerGoogleType.MARKER_WAYPOINT, RAMDOMCOLOR, string.Empty);
                            GMapOverlay.Markers.Add(WAYPOINT);
                            WAYPOINTS.Add(WAYPOINT.Position);
                        }
                    }

                    GMarkerGoogle DESTINO = new GMarkerGoogle(IFretamento.I5_DEST_COORDENADAS, GMarkerGoogleType.MARKER_END, RAMDOMCOLOR, string.Empty);
                    GMapOverlay.Markers.Add(DESTINO);
                    WAYPOINTS.Add(DESTINO.Position);

                    GDirections          GDirections          = new GDirections();
                    DirectionsStatusCode DirectionsStatusCode = DirectionsStatusCode.UNKNOWN_ERROR;
                    DirectionsStatusCode = GoogleMapProvider.Instance.GetDirections(out GDirections, WAYPOINTS.First(), WAYPOINTS.Where(x => x != WAYPOINTS.First() && x != WAYPOINTS.Last()).ToList(), WAYPOINTS.Last(), false, true, false, false, true);
                    if (DirectionsStatusCode != DirectionsStatusCode.OK)
                    {
                    }

                    if (DirectionsStatusCode == DirectionsStatusCode.OK)
                    {
                        GMapRoute GMapRoute = new GMapRoute(GDirections.Route, "Rota Planejada");
                        GMapRoute.Stroke       = (Pen)GMapRoute.Stroke.Clone();
                        GMapRoute.Stroke.Color = RAMDOMCOLOR;
                        GMapRoute.Stroke.Width = 5;
                        GMapOverlay.Routes.Add(GMapRoute);
                        GMapControl.Refresh();
                    }
                }
            }

            GMapControl.Refresh();
        }
Example #4
0
 public DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, PointLatLng end,
                                           bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     return(GetDirectionsUrl(MakeRoutingUrl(start,
                                            end,
                                            walkingMode ? TravelTypeFoot : TravelTypeMotorCar,
                                            LanguageStr,
                                            metric ? "km" : "miles"),
                             out direction));
 }
Example #5
0
        public override double GetDistance(PointLatLng point)
        {
            GDirections direction = new GDirections();

            GMapProviders.GoogleMap.GetDirections(out direction, Point, point, false, false, true, false, false);
            var d = direction.DistanceValue;

            GeoCoordinate p1 = new GeoCoordinate(point.Lat, point.Lng);
            GeoCoordinate p2 = new GeoCoordinate(Point.Lat, Point.Lng);

            return(p1.GetDistanceTo(p2));
        }
Example #6
0
        public void SetInformationAboutRoute(GDirections diraction, int idVisitedRoute)
        {
            startCoordinatesLat = diraction.StartLocation.Lat;
            startCoordinatesLng = diraction.StartLocation.Lng;

            finishCoordinatesLat = diraction.EndLocation.Lat;
            finishCoordinatesLng = diraction.EndLocation.Lng;

            Distance = diraction.Distance;
            Duration = diraction.Duration;

            listIdVisitedRoutes.Add(idVisitedRoute);
            WayToExcursionRoute = Helper.ListLatLngToString(diraction.Route);
        }
Example #7
0
        public static Task <IEnumerable <string> > GetAddressesForPositionAsync(Position position)
        {
            var point     = new PointLatLng(position.Latitude, position.Longitude);
            var direction = new GDirections();
            var addresses = new List <string>();

            GMapProviders.GoogleMap.GetDirections(out direction, point, point, false, true, false, false, true);

            if (!string.IsNullOrEmpty(direction.StartAddress))
            {
                addresses.Add(direction.StartAddress);
            }

            return(Task.FromResult <IEnumerable <string> >(addresses));
        }
Example #8
0
        private void generarRuta(string CPartida, string CDestino)
        {
            String[] inicio = CPartida.Split('*'); //textBoxPartida.Text.Split('*');
            double   i1     = Double.Parse(inicio[0]);
            double   i2     = Double.Parse(inicio[1]);

            string[] fin = CDestino.Split('*'); //textBoxDestino.Text.Split('*');
            double   f1  = Double.Parse(fin[0]);
            double   f2  = Double.Parse(fin[1]);

            PointLatLng start = new PointLatLng(i1, i2);
            PointLatLng end   = new PointLatLng(f1, f2);
            GDirections ss    = new GDirections();

            try
            {
                // var xx = GMapProviders.BingMap.GetRoute(start, end, false, false, 10);
                var       xx   = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, true, false, false);
                GMapRoute ruta = new GMapRoute(ss.Route, "Mi ruta");
                ruta.Stroke = new Pen(Color.Red, 3);
                //routes.Routes.Add(ruta);
                marcadores.Routes.Add(ruta);
                gMapRutas.Overlays.Add(marcadores);
                gMapRutas.ZoomAndCenterRoute(ruta);
                gMapRutas.ReloadMap();
            }
            catch (Exception d)
            {
                i1++;
                i2++;
                f1++;
                f2++;
                string c1 = i1 + "*" + i2;
                string c2 = f1 + "*" + f2;
                start = new PointLatLng(i1, i2);
                end   = new PointLatLng(f1, f2);
                var       xx   = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, true, false, false);
                GMapRoute ruta = new GMapRoute(ss.Route, "Mi ruta");

                ruta.Stroke = new Pen(Color.Red, 3);
                //routes.Routes.Add(ruta);
                marcadores.Routes.Add(ruta);
                gMapRutas.Overlays.Add(marcadores);
                gMapRutas.ZoomAndCenterRoute(ruta);
                gMapRutas.ReloadMap();
            }
        }
Example #9
0
        //POST: odata/Usuarios/ObtenerDireccion
        //Parametros: latInicio,lngInicio,latFinal,lngFinal
        public GDirections ObtenerDireccion(ODataActionParameters parameters)
        {
            if (parameters == null)
            {
                return(null);
            }

            double latInicio = (double)parameters["latInicio"];
            double lngInicio = (double)parameters["lngInicio"];

            double latFinal = (double)parameters["latFinal"];
            double lngFinal = (double)parameters["lngFinal"];

            GDirections direccion = Posicion.ObtenerDireccion(latInicio, lngInicio, latFinal, lngFinal);

            return(direccion);
        }
        public GMapRoute buscarRutaRecomendada(int viaje)
        {
            iu_registrarOrden4.listaDeMapas[viaje].Refresh();
            PointLatLng        laObra    = new PointLatLng(-31.4671849, -64.2239958);
            GDirections        direccion = new GDirections();
            GeoCoderStatusCode status    = new GeoCoderStatusCode();
            string             hasta     = EntregaColeccion[viaje].NombreCalle + ", " + EntregaColeccion[viaje].NumeroCalle + ", " + EntregaColeccion[viaje].NombreProvincia + ", Argentina";
            var puntoFin = GMapProviders.GoogleMap.GetPoint(hasta, out status);

            if (puntoFin == null)
            {
                var       RutasDireccion = GMapProviders.GoogleMap.GetDirections(out direccion, laObra, laObra, false, false, false, false, false);
                GMapRoute rutaObtenida   = new GMapRoute(direccion.Route, "Ruta");
                return(rutaObtenida);
            }
            else
            {
                var       RutasDireccion = GMapProviders.GoogleMap.GetDirections(out direccion, laObra, puntoFin.Value, false, false, false, false, false);
                GMapRoute rutaObtenida   = new GMapRoute(direccion.Route, "Ruta");
                return(rutaObtenida);
            }
        }
Example #11
0
 public DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
    return GetDirectionsUrl(MakeRoutingUrl(start, end, walkingMode ? TravelTypeFoot : TravelTypeMotorCar, LanguageStr, metric ? "km" : "miles"), out direction);
 }
Example #12
0
 static Map()
 {
     m_gDiractiaon = new GDirections();
 }
Example #13
0
        DirectionsStatusCode GetDirectionsUrl(string url, out GDirections direction)
        {
            DirectionsStatusCode ret = DirectionsStatusCode.UNKNOWN_ERROR;

            direction = null;

            try
            {
                string route = GMaps.Instance.UseRouteCache
                    ? Cache.Instance.GetContent(url, CacheType.DirectionsCache, TimeSpan.FromHours(TTLCache))
                    : string.Empty;
                if (string.IsNullOrEmpty(route))
                {
                    route = GetContentUsingHttp(url);
                    if (!string.IsNullOrEmpty(route))
                    {
                        if (GMaps.Instance.UseRouteCache)
                        {
                            Cache.Instance.SaveContent(url, CacheType.DirectionsCache, route);
                        }
                    }
                }

                #region -- gpx response --

                //<?xml version="1.0" encoding="UTF-8"?>
                //<gpx creator="" version="1.1" xmlns="http://www.topografix.com/GPX/1/1"
                //    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                //    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 gpx.xsd ">
                //    <extensions>
                //        <distance>293</distance>
                //        <time>34</time>
                //        <start>Perckhoevelaan</start>
                //        <end>Goudenregenlaan</end>
                //    </extensions>
                //    <wpt lat="51.17702" lon="4.39630" />
                //    <wpt lat="51.17656" lon="4.39655" />
                //    <wpt lat="51.17639" lon="4.39670" />
                //    <wpt lat="51.17612" lon="4.39696" />
                //    <wpt lat="51.17640" lon="4.39767" />
                //    <wpt lat="51.17668" lon="4.39828" />
                //    <wpt lat="51.17628" lon="4.39874" />
                //    <wpt lat="51.17618" lon="4.39888" />
                //    <rte>
                //        <rtept lat="51.17702" lon="4.39630">
                //            <desc>Head south on Perckhoevelaan, 0.1 km</desc>
                //            <extensions>
                //                <distance>111</distance>
                //                <time>13</time>
                //                <offset>0</offset>
                //                <distance-text>0.1 km</distance-text>
                //                <direction>S</direction>
                //                <azimuth>160.6</azimuth>
                //            </extensions>
                //        </rtept>
                //        <rtept lat="51.17612" lon="4.39696">
                //            <desc>Turn left at Laarstraat, 0.1 km</desc>
                //            <extensions>
                //                <distance>112</distance>
                //                <time>13</time>
                //                <offset>3</offset>
                //                <distance-text>0.1 km</distance-text>
                //                <direction>NE</direction>
                //                <azimuth>58.1</azimuth>
                //                <turn>TL</turn>
                //                <turn-angle>269.0</turn-angle>
                //            </extensions>
                //        </rtept>
                //        <rtept lat="51.17668" lon="4.39828">
                //            <desc>Turn right at Goudenregenlaan, 70 m</desc>
                //            <extensions>
                //                <distance>70</distance>
                //                <time>8</time>
                //                <offset>5</offset>
                //                <distance-text>70 m</distance-text>
                //                <direction>SE</direction>
                //                <azimuth>143.4</azimuth>
                //                <turn>TR</turn>
                //                <turn-angle>89.8</turn-angle>
                //            </extensions>
                //        </rtept>
                //    </rte>
                //</gpx>

                #endregion

                if (!string.IsNullOrEmpty(route))
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.LoadXml(route);
                    XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmldoc.NameTable);
                    xmlnsManager.AddNamespace("sm", "http://www.topografix.com/GPX/1/1");

                    XmlNodeList wpts = xmldoc.SelectNodes("/sm:gpx/sm:wpt", xmlnsManager);
                    if (wpts != null && wpts.Count > 0)
                    {
                        ret = DirectionsStatusCode.OK;

                        direction       = new GDirections();
                        direction.Route = new List <PointLatLng>();

                        foreach (XmlNode w in wpts)
                        {
                            double lat = double.Parse(w.Attributes["lat"].InnerText, CultureInfo.InvariantCulture);
                            double lng = double.Parse(w.Attributes["lon"].InnerText, CultureInfo.InvariantCulture);
                            direction.Route.Add(new PointLatLng(lat, lng));
                        }

                        if (direction.Route.Count > 0)
                        {
                            direction.StartLocation = direction.Route[0];
                            direction.EndLocation   = direction.Route[direction.Route.Count - 1];
                        }

                        XmlNode n = xmldoc.SelectSingleNode("/sm:gpx/sm:metadata/sm:copyright/sm:license",
                                                            xmlnsManager);
                        if (n != null)
                        {
                            direction.Copyrights = n.InnerText;
                        }

                        n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:distance", xmlnsManager);
                        if (n != null)
                        {
                            direction.Distance = n.InnerText + "m";
                        }

                        n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:time", xmlnsManager);
                        if (n != null)
                        {
                            direction.Duration = n.InnerText + "s";
                        }

                        n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:start", xmlnsManager);
                        if (n != null)
                        {
                            direction.StartAddress = n.InnerText;
                        }

                        n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:end", xmlnsManager);
                        if (n != null)
                        {
                            direction.EndAddress = n.InnerText;
                        }

                        wpts = xmldoc.SelectNodes("/sm:gpx/sm:rte/sm:rtept", xmlnsManager);
                        if (wpts != null && wpts.Count > 0)
                        {
                            direction.Steps = new List <GDirectionStep>();

                            foreach (XmlNode w in wpts)
                            {
                                GDirectionStep step = new GDirectionStep();

                                double lat = double.Parse(w.Attributes["lat"].InnerText, CultureInfo.InvariantCulture);
                                double lng = double.Parse(w.Attributes["lon"].InnerText, CultureInfo.InvariantCulture);

                                step.StartLocation = new PointLatLng(lat, lng);

                                XmlNode nn = w.SelectSingleNode("sm:desc", xmlnsManager);
                                if (nn != null)
                                {
                                    step.HtmlInstructions = nn.InnerText;
                                }

                                nn = w.SelectSingleNode("sm:extensions/sm:distance-text", xmlnsManager);
                                if (nn != null)
                                {
                                    step.Distance = nn.InnerText;
                                }

                                nn = w.SelectSingleNode("sm:extensions/sm:time", xmlnsManager);
                                if (nn != null)
                                {
                                    step.Duration = nn.InnerText + "s";
                                }

                                direction.Steps.Add(step);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ret       = DirectionsStatusCode.EXCEPTION_IN_CODE;
                direction = null;
                Debug.WriteLine("GetDirectionsUrl: " + ex);
            }

            return(ret);
        }
Example #14
0
 /// <summary>
 ///     NotImplemented
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="start"></param>
 /// <param name="wayPoints"></param>
 /// <param name="avoidHighways"></param>
 /// <param name="avoidTolls"></param>
 /// <param name="walkingMode"></param>
 /// <param name="sensor"></param>
 /// <param name="metric"></param>
 /// <returns></returns>
 public DirectionsStatusCode GetDirections(out GDirections direction, string start,
                                           IEnumerable <string> wayPoints, string end, bool avoidHighways, bool avoidTolls, bool walkingMode,
                                           bool sensor, bool metric)
 {
     throw new NotImplementedException();
 }
Example #15
0
        private void DrawMapRouteAndMarkers(int carNumber)
        {
            // TODO: refactor
            try
            {
                this.markersOverlay.Markers.Clear();
                this.routesOverlay.Routes.Clear();
                this.gMapControl1.Overlays.Clear();

                if (resultAddressesNames[carNumber].Count == 2) // XD Car without route
                {
                    return;
                }

                // Markers
                for (int i = 0; i < resultAddressesNames[carNumber].Count - 1; i++)
                {
                    var markerAddress          = AddressesNames.Find(x => x.name == resultAddressesNames[carNumber][i]);
                    GmapMarkerWithLabel marker = new GmapMarkerWithLabel(
                        new PointLatLng(Convert.ToDouble(markerAddress.addressCoordinates.latitude),
                                        Convert.ToDouble(markerAddress.addressCoordinates.longitude)),
                        (i + 1).ToString(),
                        GMarkerGoogleType.green
                        );
                    this.markersOverlay.Markers.Add(marker);
                }

                // Routes
                List <PointLatLng> RoutePoints = new List <PointLatLng>();
                for (int i = 0; i < resultAddressesNames[carNumber].Count - 1; i++)
                {
                    var         startAddress = AddressesNames.Find(x => x.name == resultAddressesNames[carNumber][i]);
                    var         endAddress   = AddressesNames.Find(x => x.name == resultAddressesNames[carNumber][i + 1]);
                    PointLatLng start        = new GMap.NET.PointLatLng(
                        Convert.ToDouble(startAddress.addressCoordinates.latitude),
                        Convert.ToDouble(startAddress.addressCoordinates.longitude)
                        );
                    PointLatLng end = new GMap.NET.PointLatLng(
                        Convert.ToDouble(endAddress.addressCoordinates.latitude),
                        Convert.ToDouble(endAddress.addressCoordinates.longitude)
                        );
                    GDirections ss = null;
                    var         xx = GMap.NET.MapProviders.GMapProviders.GoogleMap.GetDirections(
                        out ss, start, end, false, false, false, false, true
                        );

                    RoutePoints.AddRange(ss.Route);
                }

                GMapRoute route = new GMapRoute(RoutePoints, "My route");
                route.Stroke = new Pen(Color.Orange, 2);
                this.routesOverlay.Routes.Add(route);
                this.gMapControl1.Overlays.Add(routesOverlay);
                this.gMapControl1.Overlays.Add(markersOverlay);
            }
            catch (Exception drawingException)
            {
                // TODO: do something
                Console.WriteLine("Route drawing error");
            }
        }
 /// <summary>
 /// Método que faz pedido ao servidor de mapa para obter as direções da rota com moradas.
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="avoidHighways"></param>
 /// <param name="avoidTolls"></param>
 /// <param name="walkingMode"></param>
 /// <param name="sensor"></param>
 /// <param name="metric"></param>
 /// <returns>Status do pedido</returns>
 public virtual DirectionsStatusCode GetDirections(out GDirections direction, string start, string end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     direction = null;
     return(DirectionsStatusCode.UNKNOWN_ERROR);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="avoidHighways"></param>
 /// <param name="avoidTolls"></param>
 /// <param name="walkingMode"></param>
 /// <param name="sensor"></param>
 /// <param name="metric"></param>
 /// <returns></returns>
 public override DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     return(GoogleMapProvider.Instance.GetDirections(out direction, start, end, avoidHighways, avoidTolls, walkingMode, sensor, metric));
 }
Example #18
0
        private void button2_Click(object sender, EventArgs e)
        {
            //aqui agrego el usuario actual
            principal.Sirtru.Actual = principal.UsuarioActual;


            string hora  = "";
            string fecha = "";


            //aqui la hora
            // hora = dateTimePicker2.Value + "";

            //fecha
            fecha = dateTimePicker1.Value + "";

            //Aqui los lugares de destino y partida que serian las COORDENADAS
            String partida = CPartida;
            String destino = CDestino;


            //Cupos siempre sera 0 cuando se compra


            String[] inicio = partida.Split('*'); //textBoxPartida.Text.Split('*');
            double   i1     = Double.Parse(inicio[0]);
            double   i2     = Double.Parse(inicio[1]);

            string[] fin = destino.Split('*'); //textBoxDestino.Text.Split('*');
            double   f1  = Double.Parse(fin[0]);
            double   f2  = Double.Parse(fin[1]);

            PointLatLng start = new PointLatLng(i1, i2);
            PointLatLng end   = new PointLatLng(f1, f2);
            GDirections ss    = new GDirections();

            try
            {
                var xx = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, true, false, false);
            }
            catch (Exception d)
            {
                i1++;
                i2++;
                f1++;
                f2++;
                string c1 = i1 + "*" + i2;
                string c2 = f1 + "*" + f2;
                start = new PointLatLng(i1, i2);
                end   = new PointLatLng(f1, f2);
                var xx = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, true, false, false);
            }

            //RecomendacionUsu.

            principal.Sirtru.agregarServicio(principal.Sirtru.Actual.Id, fecha, 0, partida, destino, ss.StartAddress, ss.EndAddress, principal.Sirtru.IdServicio, "COM");

            if (principal.UsuarioActual.Tipo.Equals("c"))
            {
                InfoUsuarioCON.infoC.cargarData();
            }
            else
            {
                infoUsuarioSIN.infoS.cargarData();
            }

            MessageBox.Show("El servicio se ha registrado con exito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Hide();
        }
 public DirectionsStatusCode GetDirections(out GDirections direction, string start, IEnumerable<string> wayPoints, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     return GetDirectionsUrl(MakeDirectionsUrl(start, wayPoints, LanguageStr, avoidHighways, avoidTolls, walkingMode, sensor, metric), out direction);
 }
 public Map()
 {
     m_overlayMarkers = new GMapOverlay();
     m_overlayRoute   = new GMapOverlay();
     m_gDiractiaon    = new GDirections();
 }
 public DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     return GetDirectionsUrl(MakeDirectionsUrl(start, end, LanguageStr, avoidHighways, avoidTolls, walkingMode, sensor, metric), out direction);
 }
Example #22
0
 /// <summary>
 /// NotImplemented
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="start"></param>
 /// <param name="wayPoints"></param>
 /// <param name="avoidHighways"></param>
 /// <param name="avoidTolls"></param>
 /// <param name="walkingMode"></param>
 /// <param name="sensor"></param>
 /// <param name="metric"></param>
 /// <returns></returns>
 public DirectionsStatusCode GetDirections(out GDirections direction, string start, IEnumerable<string> wayPoints, string end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     throw new NotImplementedException();
 }
        DirectionsStatusCode GetDirectionsUrl(string url, out GDirections direction)
        {
            DirectionsStatusCode ret = DirectionsStatusCode.UNKNOWN_ERROR;
            direction = null;

            try
            {
                string kml = GMaps.Instance.UseDirectionsCache ? Cache.Instance.GetContent(url, CacheType.DirectionsCache) : string.Empty;

                bool cache = false;

                if (string.IsNullOrEmpty(kml))
                {
                    kml = GetContentUsingHttp(url);
                    if (!string.IsNullOrEmpty(kml))
                    {
                        cache = true;
                    }
                }

                if (!string.IsNullOrEmpty(kml))
                {
                    #region -- kml response --
                    //<?xml version="1.0" encoding="UTF-8"?>
                    //<DirectionsResponse>
                    // <status>OK</status>
                    // <route>
                    //  <summary>A1/E85</summary>
                    //  <leg>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.6893800</lat>
                    //     <lng>25.2800500</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.6907800</lat>
                    //     <lng>25.2798000</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>soxlIiohyCYLkCJ}@Vs@?</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>32</value>
                    //     <text>1 min</text>
                    //    </duration>
                    //    <html_instructions>Head &lt;b&gt;north&lt;/b&gt; on &lt;b&gt;Vilniaus gatvė&lt;/b&gt; toward &lt;b&gt;Tilto gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>157</value>
                    //     <text>0.2 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.6907800</lat>
                    //     <lng>25.2798000</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.6942500</lat>
                    //     <lng>25.2621300</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>kxxlIwmhyCmApUF`@GvAYpD{@dGcCjIoIvOuAhDwAtEa@vBUnDAhB?~AThDRxAh@hBtAdC</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>133</value>
                    //     <text>2 mins</text>
                    //    </duration>
                    //    <html_instructions>Turn &lt;b&gt;left&lt;/b&gt; onto &lt;b&gt;A. Goštauto gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>1326</value>
                    //     <text>1.3 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.6942500</lat>
                    //     <lng>25.2621300</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.6681200</lat>
                    //     <lng>25.2377500</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>anylIi_eyC`AwD~@oBLKr@K`U|FdF|@`J^~E[j@Lh@\hB~Bn@tBZhBLrC?zIJ~DzA~OVrELlG^lDdAtDh@hAfApA`EzCvAp@jUpIpAl@bBpAdBpBxA|BdLpV`BxClAbBhBlBbChBpBhAdAXjBHlE_@t@?|@Lt@X</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>277</value>
                    //     <text>5 mins</text>
                    //    </duration>
                    //    <html_instructions>Turn &lt;b&gt;left&lt;/b&gt; to merge onto &lt;b&gt;Geležinio Vilko gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>3806</value>
                    //     <text>3.8 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.6681200</lat>
                    //     <lng>25.2377500</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.6584100</lat>
                    //     <lng>25.1411300</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>wjtlI}f`yC~FhBlFr@jD|A~EbC~VjNxBbBdA`BnvA|zCba@l`Bt@tDTbBJpBBfBMvDaAzF}bBjiF{HnXiHxZ</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>539</value>
                    //     <text>9 mins</text>
                    //    </duration>
                    //    <html_instructions>Continue onto &lt;b&gt;Savanorių prospektas&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>8465</value>
                    //     <text>8.5 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.6584100</lat>
                    //     <lng>25.1411300</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.9358200</lat>
                    //     <lng>23.9260000</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>anrlIakmxCiq@|qCuBbLcK~n@wUrkAcPnw@gCnPoQt}AoB`MuAdHmAdFoCtJqClImBxE{DrIkQ|ZcEvIkDzIcDhKyBxJ{EdXuCtS_G`g@mF|\eF`WyDhOiE~NiErMaGpOoj@ppAoE|K_EzKeDtKkEnOsLnd@mDzLgI~U{FrNsEvJoEtI_FpI{J`O_EjFooBf_C{GdJ_FjIsH`OoFhMwH`UcDtL{CzMeDlQmAzHuU~bBiArIwApNaBfWaLfiCoBpYsDf\qChR_FlVqEpQ_ZbfA}CfN{A~HwCtRiAfKmBlVwBx[gBfRcBxMaLdp@sXrzAaE~UqCzRyC`[_q@z|LgC|e@m@vNqp@b}WuLraFo@jPaS~bDmJryAeo@v|G}CnWsm@~`EoKvo@kv@lkEkqBrlKwBvLkNj|@cu@`~EgCnNuiBpcJakAx|GyB`KqdC~fKoIfYicAxtCiDrLu@hDyBjQm@xKoGdxBmQhoGuUn|Dc@nJ[`OW|VaEn|Ee@`X</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>3506</value>
                    //     <text>58 mins</text>
                    //    </duration>
                    //    <html_instructions>Continue onto &lt;b&gt;A1/E85&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>85824</value>
                    //     <text>85.8 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.9358200</lat>
                    //     <lng>23.9260000</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.9376500</lat>
                    //     <lng>23.9195600</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>{shnIo``qCQ^MnD[lBgA`DqBdEu@xB}@zJCjB</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>39</value>
                    //     <text>1 min</text>
                    //    </duration>
                    //    <html_instructions>Take the exit toward &lt;b&gt;Senamiestis/Aleksotas&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>476</value>
                    //     <text>0.5 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.9376500</lat>
                    //     <lng>23.9195600</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.9361300</lat>
                    //     <lng>23.9189700</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>i_inIgx~pCnHtB</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>28</value>
                    //     <text>1 min</text>
                    //    </duration>
                    //    <html_instructions>Turn &lt;b&gt;left&lt;/b&gt; onto &lt;b&gt;Kleboniškio gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>173</value>
                    //     <text>0.2 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.9361300</lat>
                    //     <lng>23.9189700</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.9018900</lat>
                    //     <lng>23.8937000</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>yuhnIqt~pCvAb@JLrOvExSdHvDdAv`@pIpHnAdl@hLdB`@nDvAtEjDdCvCjLzOvAzBhC`GpHfRbQd^`JpMPt@ClA</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>412</value>
                    //     <text>7 mins</text>
                    //    </duration>
                    //    <html_instructions>Continue onto &lt;b&gt;Jonavos gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>4302</value>
                    //     <text>4.3 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.9018900</lat>
                    //     <lng>23.8937000</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.8985600</lat>
                    //     <lng>23.8933400</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>y_bnIsvypCMf@FnARlAf@zAl@^v@EZ_@pAe@x@k@xBPpA@pAQNSf@oB</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>69</value>
                    //     <text>1 min</text>
                    //    </duration>
                    //    <html_instructions>At the roundabout, take the &lt;b&gt;3rd&lt;/b&gt; exit and stay on &lt;b&gt;Jonavos gatvė&lt;/b&gt;</html_instructions>
                    //    <distance>
                    //     <value>478</value>
                    //     <text>0.5 km</text>
                    //    </distance>
                    //   </step>
                    //   <step>   
                    //    <travel_mode>DRIVING</travel_mode>
                    //    <start_location>
                    //     <lat>54.8985600</lat>
                    //     <lng>23.8933400</lng>
                    //    </start_location>
                    //    <end_location>
                    //     <lat>54.8968500</lat>
                    //     <lng>23.8930000</lng>
                    //    </end_location>
                    //    <polyline>
                    //     <points>_kanIktypCbEx@pCH</points>
                    //    </polyline>
                    //    <duration>
                    //     <value>38</value>
                    //     <text>1 min</text>
                    //    </duration>
                    //    <html_instructions>Turn &lt;b&gt;right&lt;/b&gt; onto &lt;b&gt;A. Mapu gatvė&lt;/b&gt;&lt;div style=&quot;font-size:0.9em&quot;&gt;Destination will be on the right&lt;/div&gt;</html_instructions>
                    //    <distance>
                    //     <value>192</value>
                    //     <text>0.2 km</text>
                    //    </distance>
                    //   </step>
                    //   <duration>
                    //    <value>5073</value>
                    //    <text>1 hour 25 mins</text>
                    //   </duration>
                    //   <distance>
                    //    <value>105199</value>
                    //    <text>105 km</text>
                    //   </distance>
                    //   <start_location>
                    //    <lat>54.6893800</lat>
                    //    <lng>25.2800500</lng>
                    //   </start_location>
                    //   <end_location>
                    //    <lat>54.8968500</lat>
                    //    <lng>23.8930000</lng>
                    //   </end_location>
                    //   <start_address>Vilnius, Lithuania</start_address>
                    //   <end_address>Kaunas, Lithuania</end_address>
                    //  </leg>
                    //  <copyrights>Map data ©2011 Tele Atlas</copyrights>
                    //  <overview_polyline>
                    //   <points>soxlIiohyCYL}Fb@mApUF`@GvAYpD{@dGcCjIoIvOwBpFy@xC]jBSxCC~E^~Er@lCtAdC`AwD~@oB`AW`U|FdF|@`J^~E[tAj@hB~BjA~ELrCJzOzA~Od@`N^lDdAtDt@xAjAnApDlCbXbKpAl@bBpAdBpBxA|BdLpV`BxCvDpEbChBpBhAdAXjBHbG_@|@LtHbClFr@jK`F~VjNxBbB`@h@rwAt|Cba@l`BjAxGNxEMvDaAzF}bBjiFcFbQ_y@|gD{CxMeBnJcK~n@wh@dkCkAlIoQt}AeEfV}EzQqClImBxE{DrIkQ|ZcEvIkDzIcDhKyBxJ{EdXuCtS_G`g@mF|\eF`WyDhOiE~NiErMaGpOoj@ppAoE|K_EzKeDtKmXzbAgI~U{FrNsEvJoLfT{J`O_EjFooBf_C{GdJkLtSwI`SyClI}CrJcDtL{CzMeDlQcXzlBiArIwApNaBfWaLfiCoBpYsDf\qChR_FlVqEpQ_ZbfAyFfXwCtRiAfKeFfs@gBfRcBxMaLdp@sXrzAaE~UqCzRyC`[_q@z|LuDtu@qp@b}WuLraFo@jPo^r}Faq@pfHaBtMsm@~`EoKvo@kv@lkEcuBjzKkNj|@cu@`~EgCnNuiBpcJakAx|GyB`KqdC~fKoIfYidAbwCoD|MeAbHcA|Im@xK}YnhKyV~gEs@~f@aEn|Ee@`XQ^MnD[lBoF`N}@zJCjBfKxCJLdj@bQv`@pIpHnAdl@hLdB`@nDvAtEjDdCvCbOvSzLhZbQd^`JpMPt@QtBFnAz@hDl@^j@?f@e@pAe@x@k@xBPfCEf@Uj@wBbEx@pCH</points>
                    //  </overview_polyline>
                    //  <bounds>
                    //   <southwest>
                    //    <lat>54.6389500</lat>
                    //    <lng>23.8920900</lng>
                    //   </southwest>
                    //   <northeast>
                    //    <lat>54.9376500</lat>
                    //    <lng>25.2800500</lng>
                    //   </northeast>
                    //  </bounds>
                    // </route>
                    //</DirectionsResponse> 
                    #endregion

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(kml);

                    XmlNode nn = doc.SelectSingleNode("/DirectionsResponse/status");
                    if (nn != null)
                    {
                        ret = (DirectionsStatusCode)Enum.Parse(typeof(DirectionsStatusCode), nn.InnerText, false);
                        if (ret == DirectionsStatusCode.OK)
                        {
                            if (cache && GMaps.Instance.UseDirectionsCache)
                            {
                                Cache.Instance.SaveContent(url, CacheType.DirectionsCache, kml);
                            }

                            direction = new GDirections();

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/summary");
                            if (nn != null)
                            {
                                direction.Summary = nn.InnerText;
                                Debug.WriteLine("summary: " + direction.Summary);
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/duration");
                            if (nn != null)
                            {
                                var t = nn.SelectSingleNode("text");
                                if (t != null)
                                {
                                    direction.Duration = t.InnerText;
                                    Debug.WriteLine("duration: " + direction.Duration);
                                }

                                t = nn.SelectSingleNode("value");
                                if (t != null)
                                {
                                    if (!string.IsNullOrEmpty(t.InnerText))
                                    {
                                        direction.DurationValue = uint.Parse(t.InnerText);
                                        Debug.WriteLine("value: " + direction.DurationValue);
                                    }
                                }
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/distance");
                            if (nn != null)
                            {
                                var t = nn.SelectSingleNode("text");
                                if (t != null)
                                {
                                    direction.Distance = t.InnerText;
                                    Debug.WriteLine("distance: " + direction.Distance);
                                }

                                t = nn.SelectSingleNode("value");
                                if (t != null)
                                {
                                    if (!string.IsNullOrEmpty(t.InnerText))
                                    {
                                        direction.DistanceValue = uint.Parse(t.InnerText);
                                        Debug.WriteLine("value: " + direction.DistanceValue);
                                    }
                                }
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/start_location");
                            if (nn != null)
                            {
                                var pt = nn.SelectSingleNode("lat");
                                if (pt != null)
                                {
                                    direction.StartLocation.Lat = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                }

                                pt = nn.SelectSingleNode("lng");
                                if (pt != null)
                                {
                                    direction.StartLocation.Lng = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                }
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/end_location");
                            if (nn != null)
                            {
                                var pt = nn.SelectSingleNode("lat");
                                if (pt != null)
                                {
                                    direction.EndLocation.Lat = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                }

                                pt = nn.SelectSingleNode("lng");
                                if (pt != null)
                                {
                                    direction.EndLocation.Lng = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                }
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/start_address");
                            if (nn != null)
                            {
                                direction.StartAddress = nn.InnerText;
                                Debug.WriteLine("start_address: " + direction.StartAddress);
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/leg/end_address");
                            if (nn != null)
                            {
                                direction.EndAddress = nn.InnerText;
                                Debug.WriteLine("end_address: " + direction.EndAddress);
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/copyrights");
                            if (nn != null)
                            {
                                direction.Copyrights = nn.InnerText;
                                Debug.WriteLine("copyrights: " + direction.Copyrights);
                            }

                            nn = doc.SelectSingleNode("/DirectionsResponse/route/overview_polyline/points");
                            if (nn != null)
                            {
                                direction.Route = new List<PointLatLng>();
                                DecodePointsInto(direction.Route, nn.InnerText);
                            }

                            XmlNodeList steps = doc.SelectNodes("/DirectionsResponse/route/leg/step");
                            if (steps != null)
                            {
                                if (steps.Count > 0)
                                {
                                    direction.Steps = new List<GDirectionStep>();
                                }

                                foreach (XmlNode s in steps)
                                {
                                    GDirectionStep step = new GDirectionStep();

                                    Debug.WriteLine("----------------------");
                                    nn = s.SelectSingleNode("travel_mode");
                                    if (nn != null)
                                    {
                                        step.TravelMode = nn.InnerText;
                                        Debug.WriteLine("travel_mode: " + step.TravelMode);
                                    }

                                    nn = s.SelectSingleNode("start_location");
                                    if (nn != null)
                                    {
                                        var pt = nn.SelectSingleNode("lat");
                                        if (pt != null)
                                        {
                                            step.StartLocation.Lat = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                        }

                                        pt = nn.SelectSingleNode("lng");
                                        if (pt != null)
                                        {
                                            step.StartLocation.Lng = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                        }
                                    }

                                    nn = s.SelectSingleNode("end_location");
                                    if (nn != null)
                                    {
                                        var pt = nn.SelectSingleNode("lat");
                                        if (pt != null)
                                        {
                                            step.EndLocation.Lat = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                        }

                                        pt = nn.SelectSingleNode("lng");
                                        if (pt != null)
                                        {
                                            step.EndLocation.Lng = double.Parse(pt.InnerText, CultureInfo.InvariantCulture);
                                        }
                                    }

                                    nn = s.SelectSingleNode("duration");
                                    if (nn != null)
                                    {
                                        nn = nn.SelectSingleNode("text");
                                        if (nn != null)
                                        {
                                            step.Duration = nn.InnerText;
                                            Debug.WriteLine("duration: " + step.Duration);
                                        }
                                    }

                                    nn = s.SelectSingleNode("distance");
                                    if (nn != null)
                                    {
                                        nn = nn.SelectSingleNode("text");
                                        if (nn != null)
                                        {
                                            step.Distance = nn.InnerText;
                                            Debug.WriteLine("distance: " + step.Distance);
                                        }
                                    }

                                    nn = s.SelectSingleNode("html_instructions");
                                    if (nn != null)
                                    {
                                        step.HtmlInstructions = nn.InnerText;
                                        Debug.WriteLine("html_instructions: " + step.HtmlInstructions);
                                    }

                                    nn = s.SelectSingleNode("polyline");
                                    if (nn != null)
                                    {
                                        nn = nn.SelectSingleNode("points");
                                        if (nn != null)
                                        {
                                            step.Points = new List<PointLatLng>();
                                            DecodePointsInto(step.Points, nn.InnerText);
                                        }
                                    }

                                    direction.Steps.Add(step);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                direction = null;
                ret = DirectionsStatusCode.ExceptionInCode;
                Debug.WriteLine("GetDirectionsUrl: " + ex);
            }
            return ret;
        }
Example #24
0
      DirectionsStatusCode GetDirectionsUrl(string url, out GDirections direction)
      {
         DirectionsStatusCode ret = DirectionsStatusCode.UNKNOWN_ERROR;
         direction = null;

         try
         {
            string route = GMaps.Instance.UseRouteCache ? Cache.Instance.GetContent(url, CacheType.DirectionsCache) : string.Empty;
            if(string.IsNullOrEmpty(route))
            {
               route = GetContentUsingHttp(url);
               if(!string.IsNullOrEmpty(route))
               {
                  if(GMaps.Instance.UseRouteCache)
                  {
                     Cache.Instance.SaveContent(url, CacheType.DirectionsCache, route);
                  }
               }
            }

            #region -- gpx response --
            //<?xml version="1.0" encoding="UTF-8"?>
            //<gpx creator="" version="1.1" xmlns="http://www.topografix.com/GPX/1/1"
            //    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            //    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 gpx.xsd ">
            //    <extensions>
            //        <distance>293</distance>
            //        <time>34</time>
            //        <start>Perckhoevelaan</start>
            //        <end>Goudenregenlaan</end>
            //    </extensions>
            //    <wpt lat="51.17702" lon="4.39630" />
            //    <wpt lat="51.17656" lon="4.39655" />
            //    <wpt lat="51.17639" lon="4.39670" />
            //    <wpt lat="51.17612" lon="4.39696" />
            //    <wpt lat="51.17640" lon="4.39767" />
            //    <wpt lat="51.17668" lon="4.39828" />
            //    <wpt lat="51.17628" lon="4.39874" />
            //    <wpt lat="51.17618" lon="4.39888" />
            //    <rte>
            //        <rtept lat="51.17702" lon="4.39630">
            //            <desc>Head south on Perckhoevelaan, 0.1 km</desc>
            //            <extensions>
            //                <distance>111</distance>
            //                <time>13</time>
            //                <offset>0</offset>
            //                <distance-text>0.1 km</distance-text>
            //                <direction>S</direction>
            //                <azimuth>160.6</azimuth>
            //            </extensions>
            //        </rtept>
            //        <rtept lat="51.17612" lon="4.39696">
            //            <desc>Turn left at Laarstraat, 0.1 km</desc>
            //            <extensions>
            //                <distance>112</distance>
            //                <time>13</time>
            //                <offset>3</offset>
            //                <distance-text>0.1 km</distance-text>
            //                <direction>NE</direction>
            //                <azimuth>58.1</azimuth>
            //                <turn>TL</turn>
            //                <turn-angle>269.0</turn-angle>
            //            </extensions>
            //        </rtept>
            //        <rtept lat="51.17668" lon="4.39828">
            //            <desc>Turn right at Goudenregenlaan, 70 m</desc>
            //            <extensions>
            //                <distance>70</distance>
            //                <time>8</time>
            //                <offset>5</offset>
            //                <distance-text>70 m</distance-text>
            //                <direction>SE</direction>
            //                <azimuth>143.4</azimuth>
            //                <turn>TR</turn>
            //                <turn-angle>89.8</turn-angle>
            //            </extensions>
            //        </rtept>
            //    </rte>
            //</gpx> 
            #endregion

            if(!string.IsNullOrEmpty(route))
            {
               XmlDocument xmldoc = new XmlDocument();
               xmldoc.LoadXml(route);
               System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xmldoc.NameTable);
               xmlnsManager.AddNamespace("sm", "http://www.topografix.com/GPX/1/1");

               XmlNodeList wpts = xmldoc.SelectNodes("/sm:gpx/sm:wpt", xmlnsManager);
               if(wpts != null && wpts.Count > 0)
               {
                  ret = DirectionsStatusCode.OK;

                  direction = new GDirections();
                  direction.Route = new List<PointLatLng>();

                  foreach(XmlNode w in wpts)
                  {
                     double lat = double.Parse(w.Attributes["lat"].InnerText, CultureInfo.InvariantCulture);
                     double lng = double.Parse(w.Attributes["lon"].InnerText, CultureInfo.InvariantCulture);
                     direction.Route.Add(new PointLatLng(lat, lng));
                  }

                  if(direction.Route.Count > 0)
                  {
                     direction.StartLocation = direction.Route[0];
                     direction.EndLocation = direction.Route[direction.Route.Count - 1];
                  }

                  XmlNode n = xmldoc.SelectSingleNode("/sm:gpx/sm:metadata/sm:copyright/sm:license", xmlnsManager);
                  if(n != null)
                  {
                     direction.Copyrights = n.InnerText;
                  }

                  n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:distance", xmlnsManager);
                  if(n != null)
                  {
                     direction.Distance = n.InnerText + "m";
                  }

                  n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:time", xmlnsManager);
                  if(n != null)
                  {
                     direction.Duration = n.InnerText + "s";
                  }

                  n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:start", xmlnsManager);
                  if(n != null)
                  {
                     direction.StartAddress = n.InnerText;
                  }

                  n = xmldoc.SelectSingleNode("/sm:gpx/sm:extensions/sm:end", xmlnsManager);
                  if(n != null)
                  {
                     direction.EndAddress = n.InnerText;
                  }

                  wpts = xmldoc.SelectNodes("/sm:gpx/sm:rte/sm:rtept", xmlnsManager);
                  if(wpts != null && wpts.Count > 0)
                  {
                     direction.Steps = new List<GDirectionStep>();

                     foreach(XmlNode w in wpts)
                     {
                        GDirectionStep step = new GDirectionStep();

                        double lat = double.Parse(w.Attributes["lat"].InnerText, CultureInfo.InvariantCulture);
                        double lng = double.Parse(w.Attributes["lon"].InnerText, CultureInfo.InvariantCulture);

                        step.StartLocation = new PointLatLng(lat, lng);

                        XmlNode nn = w.SelectSingleNode("sm:desc", xmlnsManager);
                        if(nn != null)
                        {
                           step.HtmlInstructions = nn.InnerText;
                        }

                        nn = w.SelectSingleNode("sm:extensions/sm:distance-text", xmlnsManager);
                        if(nn != null)
                        {
                           step.Distance = nn.InnerText;
                        }

                        nn = w.SelectSingleNode("sm:extensions/sm:time", xmlnsManager);
                        if(nn != null)
                        {
                           step.Duration = nn.InnerText + "s";
                        }

                        direction.Steps.Add(step);
                     }
                  }
               }
            }
         }
         catch(Exception ex)
         {
            ret = DirectionsStatusCode.ExceptionInCode;
            direction = null;
            Debug.WriteLine("GetDirectionsUrl: " + ex);
         }

         return ret;
      }