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 6 of 6

saving mappoint route in a file

This is a discussion on saving mappoint route in a file within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello, what I'm trying to do is to create a route with mappoint and then to save it in a ...

  1. #1
    giaarcix is offline Junior Member Yellow Belt
    Join Date
    May 2006
    Posts
    13

    saving mappoint route in a file

    Hello,
    what I'm trying to do is to create a route with mappoint and then to save it in a file.
    My program should be able to build some routes for different cars, and this part is ok.
    Then I need to save all the routes somewhere in my pc, so that I'll be able to pick a car and to see the relative route.
    But I don't need an image of the route: I need an object witch I can use in my code. Is this possible?
    I hope I've been clear..... Thank you very much,

    Giacomo from Italy
    Bisogna sognare, insistere, ripetere, finchŔ il sogno si trasformi in realtÓ

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Yes easy to do:

    Code:
        for (int i = 0; i < route.Directions.Count; i++) {
            object o = i;
            MapPoint.Direction direction = route.Directions.get_Item(ref o);
            // here you have each direction with all his properties
        }
    You cannot use foreach because foreach is not in the right sequence !

  3. #3
    giaarcix is offline Junior Member Yellow Belt
    Join Date
    May 2006
    Posts
    13

    Other question...

    Hi,
    I'm back on the problem. Actually I am writing code in Visual Basic on Mappoint 2006.
    To save the route I did so:

    For i = 1 To objRoute.Directions.Count
    Set objLoc = objRoute.Directions.Item(i).Location
    coordinates = get_coordinates_from_objloc(objLoc) 'My routine
    Call save_coordinates(coordinates, "my_car") 'My routine
    Next

    I create an objLoc for each direction into the objRoute, I find the coordinates of every objLoc and I save them into a text file so that when I quit the program I have still saved into my computer the route.
    BUT: is there another way to do this? It seems to me to be a so long process if the route is very long... and I'm not sure that my routine get_coordinates_from_objloc(objLoc) works perfectly!
    Isn't there a way to save the objRoute directly into a file?
    Thank you so much!

    Giacomo from Italy
    Bisogna sognare, insistere, ripetere, finchŔ il sogno si trasformi in realtÓ

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    As far as I know there is no other way. But I think this way will be fast, and you must be sure that your get_coordinates_from_objloc(objLoc) works perfecly

  5. #5
    giaarcix is offline Junior Member Yellow Belt
    Join Date
    May 2006
    Posts
    13

    But....

    Thank you.. actually I've just realized that the bug is not into my function get_coordinates_from_objloc(objLoc)! It seems to be into the objRoute.Directions!
    Try running this code (this time on Mappoint2004, actually I can't try on 2006).
    You'll see that the route is well calculated beetween Milan and Rome, but when I cicle on the directions not all the waypoints are the right ones.
    Is there something wrong in my code (where???), or, as I believe, there is bug in Mappoint?

    Private Sub Form_Load()

    Dim objMap As MapPointctl.Map
    Dim objLoc1 As MapPointctl.Location
    Dim objLoc2 As MapPointctl.Location
    Dim objLoc3 As MapPointctl.Location
    Dim objpushpin As MapPointctl.Pushpin

    MappointControl1.NewMap geoMapEurope

    Set objMap = MappointControl1.ActiveMap

    Set objMap = MappointControl1.ActiveMap
    Set objRoute = objMap.ActiveRoute

    Set objLoc1 = objMap.FindResults("Milan")(1)
    Set objLoc2 = objMap.FindResults("Rome")(1)

    objRoute.Waypoints.Add objLoc1
    objRoute.Waypoints.Add objLoc2

    objRoute.Calculate
    MappointControl1.ItineraryVisible = False

    For i = 1 To objRoute.Directions.Count
    Set objLoc3 = objRoute.Directions.Item(i).Location

    Set objpushpin = objMap.AddPushpin(objLoc3)
    objpushpin.Highlight = True
    objLoc3.GoTo

    Next

    End Sub
    Bisogna sognare, insistere, ripetere, finchŔ il sogno si trasformi in realtÓ

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    You have to check if the given item is indeed a waypoint.
    In C# it is something like this:

    Code:
    for (int i = 1; i <= route.Directions.Count; i++) {
            o = i;
            object wp = route.Directions.get_Item(ref o) as Waypoint;
            if (wp == null)
                continue;
            // and here the rest of your code
    Should be something similar in VB, but if I try to do it I will type more syntax errors and confuse everyone including myself

    I tryed it out and the strange pushpins (one even 15 km of the route) are away now

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. MapPoint hangs when saving map as HTML
    By tfmiltz in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-13-2005, 02:16 PM
  2. Saving Updated Territories from the MapPoint ActiveX Control
    By pauldivaniii in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 05-25-2005, 12:18 AM
  3. Closing without saving
    By Mudrover in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-30-2005, 08:49 AM
  4. Tracking Route And Save To File (possible to do this?)
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 04-08-2004, 07:14 AM
  5. Pushpins of Legend while saving file as .htm
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-24-2003, 01:32 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