Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

MapPoint Programming.... Creating a Route

This is a discussion on MapPoint Programming.... Creating a Route within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, Okay I am doing some research for my company into if MapPoint will do what we need. Heres the ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    MapPoint Programming.... Creating a Route

    Hi,

    Okay I am doing some research for my company into if MapPoint will do what we need.

    Heres the deal, what we would need to do, is import into MapPoint a list of addresses (we would mainly be working on Post Codes / Zip Codes etc) and then generate a map with a route on it from these.

    My original idea after reading through the technical info for MapPoint was to this:

    Code:
    Dim mpApplication As MapPoint.Application
    Dim mpDataSets As MapPoint.DataSets
    Dim mpDataSet As MapPoint.DataSet
    Dim mpRecordSet as MapPoint.Recordset
    Dim mpMap As MapPoint.Map
    Dim mpRoute As MapPoint.Route
    Dim mpFieldDefList(4,2) As Variant
    
    mpFieldDefList(1,1) = “ROUTENO”
    mpFieldDefList(1,2) = geoFieldData 	‘//Non Geocoding Data
    
    mpFieldDefList(2,1) = “CLIENTNAME”
    mpFieldDefList(2,2) = geoFieldData
    
    mpFieldDefList(3,1) = “ADDRESSINFO”
    mpFieldDefList(3,2) = geoFieldData
    
    mpFieldDefList(4,1) = “POSTALCODE”
    mpFieldDefList(4,2) = geoFieldPostal1  ‘UK Post Code Data Type
    
    
    Set mpAplication = New MapPoint.Application
    mpApplication.Visible = False
    mpApplication.UserControl = False
    
    mpApplication.NewMap
    
    Set mpMap = mpApplication.ActiveMap
    Set mpRoute = mpMap.ActiveRoute
    
    Set mpDataSets = mpApplication.NewMap.DataSets
    
    Set mpDataSet = mpDataSets.ImportData(gblProgramDatabasePath & “!tblMapRouteData”, mpFieldDefList)
    
    Set mpRecordset = mpDataSet.QueryAllRecords
    Now it is at this point I got stuck, I was under the impression I could something like this:

    Code:
    mpRecordset.MoveFirst
    Do Until mpRecordset.EOF
        mpRoute.WayPoints.Add(mpRecordset("POSTALCODE").Value)
        mpRecordset.MoveNext
    Loop
    I know thats very crude, but its just an example of the idea I had. I thought I would probably need some kind of function to return perhaps a geographic co-ordinate based on the post code I am passing etc...

    But I got stuck when I realised that a WayPoint object requires something called an "Anchor" which can either be a Locaton object or pushpin object.

    Now I am totally confused after reading Microsofts documentation on how the hell Pushpins work. I read somewhere that an imported data set already has pushpins... but what do these pushpins represent, each record in the dataset? I know pushpins represent marks on the map, I get that, but how do they relate to all this.

    How do I get from my post codes in my dataset, to a pushpin object which can be used as an achor for a waypoint object that I want to add to my route.

    Basically any help you can offer or information to boost my understanding would be very welcome.

    Thanks

    - Paul

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Oh and my second question is this,

    Granted the above code is Visual Basic, however my company writes all its software in Borland Delphi, so I am wondering if there is going to be any issues there?

    I mean in theroy, because it works using COM, and Delphi supports COM and can create a Delphi object wrapper for the MapPoint Object Library so Delphi can work with it, it shouldn't be a problem.. but will it ?

    Just to give you some background, the reason we want to use MapPoint is because we have a peice of software that is used in meal deliveries. We want to build in the ability for a customer to see an actual map with their delivery routes on that.

    - Paul

  3. #3
    frankp is offline Junior Member White Belt
    Join Date
    Dec 2003
    Posts
    10

    Re: MapPoint Programming.... Creating a Route

    Quote Originally Posted by Anonymous
    How do I get from my post codes in my dataset, to a pushpin object which can be used as an achor for a waypoint object that I want to add to my route.
    Here's the code I use in Delphi to add waypoints to a route:

    var
    ONE : OleVariant;
    FR : FindResults;
    Pin : PushPin;

    While not MemMappingData.EOF do
    begin

    FR := mpMap.FindAddressResults( MemMappingData.FieldByName('Address1').AsString, MemMappingData.FieldByName('City').AsString,'',Mem MappingData.FieldByName('State').AsString, MemMappingData.FieldByName('ZIP').AsString,geoCoun tryUnitedStates)

    Pin := mpMap.AddPushPin( Location(FR.Item[ONE]), MemMappingData.FieldByName('Name').AsString );

    Route.Waypoints.Add( Pin );

    MemMappingData.Next;

    end;

    // Check to make sure there's more than 1 waypoint before Calculating the Route...
    if Route.Waypoints.Count > 1 then Route.Calculate;


    That should get you started. I don't want to help you too much... my software is for a meal delivery service as well!

    Phil Frank

  4. #4
    Syd
    Syd is offline Member Yellow Belt
    Join Date
    Aug 2003
    Posts
    42

    Planning a route

    Hi there,

    you first search for the address with .Findresult() and then add the first address found to the route?

    What if the address is not the first item of the result list? you'll get a wrong route then. It should be the first, but you can't know exactly if the adress is right in the recordset or in mappoint itself.

    I do it that way that I'm searching for the postal code to have the right area (ok I'm in Germany and it's perhaps not the way in the United states with the adresses ? ) and then for the whole adress.

    greetings,
    Syd

    btw. if anybody has a better idea, contact me or poste it

  5. #5
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    The FindResults collection has a property called ResultsQuality that is set to geoFindResultGood, geoAmbiguousResults, etc.

    This can give you some idea as to how good MapPoint things the returned list of addresses is.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  6. #6
    frankp is offline Junior Member White Belt
    Join Date
    Dec 2003
    Posts
    10
    Quote Originally Posted by winwaed
    The FindResults collection has a property called ResultsQuality
    Yes, in the code example above I was simply illustrating how to add an address to a pushpin and then add the pushpin to a route. I do have code to check the results returned from an address that's been submitted. If there's more than one result returned I ask for user intervention.

    Phil

  7. #7
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    This worked for me:

    On Error Resume Next
    Do Until mpRecordset .EOF
    myRoute.Waypoints.Add mpRecordset .Pushpin
    mpRecordset.MoveNext
    Loop
    On Error Goto 0

    The error part is because not all pushpins will have valid locations, there is probably a better way to exclude them but I'm new to MapPoint.

  8. #8
    rbarthels is offline Member Green Belt
    Join Date
    Nov 2002
    Posts
    52
    Hi,

    I have developped a solution for creating a route based on MapPoint. I could send you the program.

    Cheers
    Rainer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ambiguous messages ( programming or not programming? )
    By Mohamed in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-13-2006, 04:35 PM
  2. Programming MapPoint via .NET
    By Anonymous in forum MP2K Magazine Articles
    Replies: 1
    Last Post: 02-21-2006, 10:42 AM
  3. Creating a Route
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-01-2003, 10:44 AM
  4. In using MapPoint in programming with VB how do yo....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-27-2001, 02:53 AM
  5. What is the "Programming Model" of Mappoint, and h....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-27-2001, 12:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96