Community of VE/MapPoint Users and Developers
This is a discussion on saving mappoint route in a file within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| saving mappoint route in a file 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à |
| |||
|
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
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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à |
| |||
|
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
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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à |
| |||
|
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
I tryed it out and the strange pushpins (one even 15 km of the route) are away now
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| file, mappoint, route, saving |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MapPoint hangs when saving map as HTML | tfmiltz | MapPoint 2006/2009 Discussion | 3 | 09-13-2005 02:16 PM |
| Saving Updated Territories from the MapPoint ActiveX Control | pauldivaniii | MapPoint 2006/2009 Discussion | 0 | 05-25-2005 12:18 AM |
| Closing without saving | Mudrover | MapPoint 2006/2009 Discussion | 1 | 01-30-2005 08:49 AM |
| Tracking Route And Save To File (possible to do this?) | Anonymous | MapPoint 2006/2009 Discussion | 2 | 04-08-2004 07:14 AM |
| Pushpins of Legend while saving file as .htm | Anonymous | MapPoint 2006/2009 Discussion | 1 | 07-24-2003 01:32 PM |