Walking Routes

Jul 29, 2009 at 3:17 AM

Hi radioman,

I added the following code to support Walking Routes ( In Beta testing by Google).  Basically clones the existing functions and sets the dirflg to "w". An alternate implementation is to alter the existing functions (GetRouteBetweenPoints and MakeRouteURL)  however existing applications would need to change.

Keep up the good work

Brian

      /// Gets a walking route (if supported)
      /// </summary>
      /// <param name="start"></param>
      /// <param name="end"></param>
      /// <param name="Zoom"></param>
      /// <returns></returns>
      public MapRoute GetWalkingRouteBetweenPoints(PointLatLng start, PointLatLng end, int Zoom)
      {
          string tooltip;
          int numLevels;
          int zoomFactor;
          MapRoute ret = null;
          List<PointLatLng> points = GetRouteBetweenPointsUrl(MakeWalkingRouteUrl(start, end, Language), Zoom, UseRouteCache, out tooltip, out numLevels, out zoomFactor);
          if (points != null)
          {
              ret = new MapRoute(points, tooltip);
          }
          return ret;
      }
      public MapRoute GetWalkingRouteBetweenPoints(string start, string end, int Zoom)
      {
          string tooltip;
          int numLevels;
          int zoomFactor;
          MapRoute ret = null;
          List<PointLatLng> points = GetRouteBetweenPointsUrl(MakeWalkingRouteUrl(start, end, Language), Zoom, UseRouteCache, out tooltip, out numLevels, out zoomFactor);
          if (points != null)
          {
              ret = new MapRoute(points, tooltip);
          }
          return ret;
      }


      internal string MakeWalkingRouteUrl(PointLatLng start, PointLatLng end, string language)
      {

          string directions = "&mra=ls&dirflg=w";

          return string.Format("http://maps.google.com/maps?f=q&output=dragdir&doflg=p&hl={0}{1}&q=&saddr=@{2},{3}&daddr=@{4},{5}", language, directions, start.Lat.ToString(CultureInfo.InvariantCulture), start.Lng.ToString(CultureInfo.InvariantCulture), end.Lat.ToString(CultureInfo.InvariantCulture), end.Lng.ToString(CultureInfo.InvariantCulture));
      }
      internal string MakeWalkingRouteUrl(string start, string end, string language)
      {
          string directions = "&mra=ls&dirflg=w";
          return string.Format("http://maps.google.com/maps?f=q&output=dragdir&doflg=p&hl={0}{1}&q=&saddr=@{2}&daddr=@{3}", language, directions, start.Replace(' ', '+'), end.Replace(' ', '+'));
      }


 

Coordinator
Jul 29, 2009 at 5:17 AM

done! tkanks