none
Limit number of viaWaypoints on route in Bing Map AJAX API 7.0 using DirectionsManager RRS feed

  • Question

  • Hi All,

    In Bing Map AJAX API 7.0, maximum of 10 viaWaypoints between each set of waypoints is allowed. I want to allow only 4 viaWaypoints between start and end address of the route using DirectionsManager class. I don't see any option to set viaWaypoints count in msdn documentation.

    So is there any way to limit viaWaypoints count (between start and end address) to specific number?

    Thursday, May 15, 2014 7:59 AM

Answers

  • I'm not aware of any configuration for this, nor have I ever had anyone ask for this. That said looking at the documentation you could do this fairly easily. Using the directions manager you can get all the waypoints using the getAllWaypoints, you could loop through this and count the number of waypoints that have the setting isViapoint set to true. If you wanted to take this a bit further you could tie into the WaypointAdded event and trigger this filter method then.

    http://rbrundritt.wordpress.com

    Thursday, May 15, 2014 1:37 PM
  • You can attach to the WaypointAdded event so that you know when a waypoint is added. You can then test to see if there are more than 4 via waypoints. If there are, then remove the last added waypoint and optionally alert the user.

    http://rbrundritt.wordpress.com

    Thursday, May 15, 2014 4:46 PM

All replies

  • I'm not aware of any configuration for this, nor have I ever had anyone ask for this. That said looking at the documentation you could do this fairly easily. Using the directions manager you can get all the waypoints using the getAllWaypoints, you could loop through this and count the number of waypoints that have the setting isViapoint set to true. If you wanted to take this a bit further you could tie into the WaypointAdded event and trigger this filter method then.

    http://rbrundritt.wordpress.com

    Thursday, May 15, 2014 1:37 PM
  • Thanks!

    Yes,  I can get viaWaypoints count using getAllWaypoints method. Suppose, as per my requirement if number of viaWaypoints count reaches to 4 then how can I stop user from placing new viaWaypoint on route. Is there any method to set that limit and event in which we need to write that code?

    Thursday, May 15, 2014 2:20 PM
  • You can attach to the WaypointAdded event so that you know when a waypoint is added. You can then test to see if there are more than 4 via waypoints. If there are, then remove the last added waypoint and optionally alert the user.

    http://rbrundritt.wordpress.com

    Thursday, May 15, 2014 4:46 PM
  • Thanks!  Above suggested logic worked.
    Friday, May 16, 2014 11:13 AM