MapPoint: My distances and times doesn't match the MapPoint WebService, or the MapPoint Windows program

Posted on 2004-11-27
Last Modified: 2008-02-01

I'm new to the MapPoint ActiveX control and have written some code to get the distance and time betwen two points.  But they don't match the MapPoint web service.  Furthermore, they don't even match the values given by the MapPoint Windows application.

So, I obviously have some problem with the way I've written the code to extact this data from MapPoint.  I've included two functions that I've coded.  The first, GetDistanceAndDuration(), returns a comma delimited string like, "1.1, 4.5";  It calls GetLocationFromAddress(), which returns a location associated with a given address.

I'd really appreciate it if someone could look over my code and give me some help.  I can't use MapPoint until I can figure out how to get good data from it.


private string GetDistanceAndDuration( string address1, string address2 )
      string returnStr = null;
      MapPoint.Route mpRoute      = MpMap.ActiveRoute; // MpMap is a property of the object

      MapPoint.Location loc1 = GetLocationFromAddress( address1 );
      mpRoute.Waypoints.Add( loc1, "loc1" );

      MapPoint.Location loc2 = GetLocationFromAddress( address2 );
      mpRoute.Waypoints.Add( loc2, "loc2" );


      Double dElapsedTime1      = mpRoute.DrivingTime;
      double duration            = Math.Round( dElapsedTime1 * 24 * 60, 1 );
      double distance            = Math.Round( mpMap.Distance( loc1, loc2 ), 1) ;
      return distance.ToString() + "," + duration.ToString();

private MapPoint.Location GetLocationFromAddress( string address )
    string[] addressSplit = address.Split(new Char[] {','});
    string street      = addressSplit[0];
    string city      = addressSplit[1];
    string state      = addressSplit[2];

    MapPoint.Map mpMap = preferences.MpMap;
    MapPoint.Route mpRoute               = mpMap.ActiveRoute;
    MapPoint.FindResults mpFindResults;
    mpFindResults = mpMap.FindAddressResults( street, city, "", state, "", 244 );

    if (mpFindResults.Count >= 1)
        mpRoute = mpMap.ActiveRoute;
        IEnumerator item = mpFindResults.GetEnumerator();

        return (MapPoint.Location)item.Current;
    return null;
Question by:ba272

    Author Comment

    Chester, if you read this, I take that back about the discussion link you sent me.  I was simply looking inside a particular thread.  It looks like a good site. Thanks.
    LVL 6

    Expert Comment


    Ok. Cool :). I don't have much experience with MapPoint. Anyway I'll try my best to help you out. I think you can use map point web service to find the distance. Why you are not using that?


    Author Comment


    I have been using that for months now.  But the problem will be latency of the web.  I need more immediate results, which only the ActiveX control can give me.  So I'm currently migrating to the desktop version of MapPoint.

    LVL 6

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now