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
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Adjusting preferred arrival setting

This is a discussion on Adjusting preferred arrival setting within the MapPoint Desktop Discussion forums, part of the Map Forums category; How can i adjust the preferred arrival and departure time of a waypoint??? I'm working with C#. I tried several ...

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

    Adjusting preferred arrival setting

    How can i adjust the preferred arrival and departure time of a waypoint??? I'm working with C#.

    I tried several options:

    way = ActiveMap.ActiveRoute.Waypoints.Add(pin,name);
    way.PreferredArrival = preferredarrivalarray[i];

    Doesn't work, it says "Access denied"

    ActiveMap.ActiveRoute.Waypoints[i].PreferredArrival = preferredarrivalarray[i];

    Also doesnt work now it says:

    "Property, indexer, or event 'this' is not supported by the language; try directly calling accessor method 'MapPoint.Waypoints.get_Item(ref object)"

    ActiveMap.ActiveRoute.Waypoints.get_Item(This expects an object but wath object????? )

    Can anyone help?

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    what is "preferredarrivalarray[i]" declared as?

    Its looking for a date.

    This is from the help file:
    Code:
    objRoute.Waypoints.Item(2).PreferredArrival = TimeValue("1:00:00 PM")

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    It are both DateTimes, the code provided by MSDN doesn't work. I also dont have the .Item option after Waypoints in C#

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    I was able to get the sample in the helpfile to work but I think you problem might be getting a reference to the waypoint item so I made another example that may give you something else to try. Hope it helps and sorry I can give an example in c#.

    Code:
    Dim objmap As MapPointCtl.Map
    Set objmap = MappointControl1.ActiveMap
    Dim objroute As MapPointCtl.Route
    Set objroute = objmap.ActiveRoute
    Dim iWaypoint As MapPointCtl.Waypoint
     
    'Add two waypoints to the map
    objroute.Waypoints.Add objmap.FindResults("Seattle, WA").Item(1)
    objroute.Waypoints.Add objmap.FindResults("Spokane, WA").Item(1)
     
     For Each iWaypoint In objroute.Waypoints
     If InStr(1, iWaypoint.Name, "Spokane", vbTextCompare) Then
     iWaypoint.PreferredArrival = TimeValue("1:00:00 PM")
     Exit For
     End If
     Next
     'Lets see if it worked
      objroute.Calculate

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    I have the following:

    for(int i = 0;i < locationarray.Length;i++)
    {
    pin = ActiveMap.FindPushpin(locationarray[i].Name);
    ActiveMap.ActiveRoute.Waypoints.Add(pushpin,locati onarray[i].Name);
    }

    foreach(MapPoint.Waypoint way in ActiveMap.ActiveRoute.Waypoints)
    {
    ay.PreferredArrival = preferredarrivalarray[teller];
    way.PreferredDeparture = preferreddeparturearray[teller];
    teller++;
    }

    If I do it this way I always get "Access Denied" while adjustting DateTime settings. I'm currently working with the .Net Framework 1.1 maybe it has something to do with this?

    thx

  6. #6
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    In this line of code why is the word way come after MapPoint.Waypoint? Maybe its just a typo?
    Code:
    foreach&#40;MapPoint.Waypoint way in ActiveMap.ActiveRoute.Waypoints&#41;
    Anyway I'm not sure what else to try. If you want to send me the C#
    .sln I can try to come up with something?

  7. #7
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Code:
    foreach&#40;MapPoint.Waypoint way in ActiveMap.ActiveRoute.Waypoints&#41;
    You have multiple waypoint object in de activeroute.waypoints so I do a for each structure to get those waypoint objects. It works like this (I get the individual waypoint objects) but I cant adjust anything (access denied message)

  8. #8
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Sorry, didn't see you meant the word way, ist a variable you use within the foreach structure.

  9. #9
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Sorry, didn't see you meant the word way, ist a variable you use within the foreach structure.

    Code:
    public void CalculateOptimalRoute&#40;Location&#91;&#93; locationarray,System.DateTime&#91;&#93; preferredarrivalarray, System.DateTime&#91;&#93; preferreddeparturearray,bool optimize&#41;
    		&#123;
    			MapPoint.Pushpin pin;
    			//MapPoint.Waypoint way;
    			//IEnumerator list; 
    			int teller = 0;
      
    			for&#40;int i = 0;i < locationarray.Length;i++&#41;
    			&#123;
    				pin = ActiveMap.FindPushpin&#40;locationarray&#91;i&#93;.Name&#41;;
    				if&#40;pin == null&#41;
    				&#123;
    				pin = ActiveMap.AddPushpin&#40;ActiveMap.GetLocation&#40;locationarray&#91;i&#93;.Latitude,locationarray&#91;i&#93;.Longitude,1&#41;,"Temppush " + locationarray&#91;i&#93;.Name&#41;;
    				MPPushpins.Add&#40;pin&#41;;  
    				&#125;
    				ActiveMap.ActiveRoute.Waypoints.Add&#40;pin,locationarray&#91;i&#93;.Name&#41;;
    				//list = ActiveMap.ActiveRoute.Waypoints.GetEnumerator&#40;&#41;;
    				//list.MoveNext&#40;&#41;; 
    				//&#40;&#40;MapPoint.Waypoint&#41;&#40;list.Current&#41;&#41;.PreferredArrival = preferredarrivalarray&#91;i&#93;;  
    
    				//ActiveMap.ActiveRoute.Waypoints.; // Item&#91;i&#93;.PreferredArrival = preferredarrivalarray&#91;i&#93;;    
    			&#125;
    
    			foreach&#40;MapPoint.Waypoints way in ActiveMap.ActiveRoute.Waypoints&#41;
    			&#123;
    				way.PreferredArrival = preferredarrivalarray&#91;teller&#93;;	
    				way.PreferredDeparture = preferreddeparturearray&#91;teller&#93;;
    				teller++;
    			&#125;
    			if&#40;optimize&#41;
    			&#123;
    				ActiveMap.ActiveRoute.Waypoints.Optimize&#40;&#41;;
    			&#125;
    			ActiveMap.ActiveRoute.Calculate&#40;&#41;;
    
    		&#125;
    This is the piece of code (never mind the things that are in comment, it was to test somse things. The idea is that you get 3 arrays. The first are the waypoint locations, second array are preferred arrival times and the last departure times.

  10. #10
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Owkee, next question:

    Is there anyway to implement the Scribble function of mappoint? I want to let the user draw a polyline on the map and i cant figure out how to do it.

    BTW

    I'm from Belgium so there's a little time delay

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Display setting for Map
    By alwasl8 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 10-07-2005, 10:37 PM
  2. How to choose Fast, Short or Preferred itineray
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-10-2004, 04:14 AM
  3. return the waypoint arrival time
    By CSG in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 06-24-2004, 07:34 AM
  4. Planning a route after arrival times
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 02-24-2003, 08:11 AM
  5. Adjusting Road Speeds
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 01-10-2003, 04:59 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