none
How do I snap a point to the nearest road using Bing Maps AJAX API v7? RRS feed

  • Question

  • I have read about a way to do this using v6.2 here: http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/bdcb49e7-8393-45f6-86fc-8e97949037b3/

    However, several of the options used in the above example (e.g. the SetBestMapView attribute) aren't to be found in v7. How do I do the same task in v7? Or are there other smarter ways?

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 10:56 AM (From:Bing Maps: Map Control and Web services Development)
    Sunday, September 18, 2011 1:17 AM

Answers

  • I'm not sure how you're adding the routeline to the map, but Bing Maps shouldn't automatically set a best view every time an entity is added to the map.

    To snap a point to the nearest (routable) road in v7, you should call the REST route service, supplying the point as both the start and end point of the route. Then, in the route callback, retrieve the first coordinate in the result.resourceSets[0].resources[0].routePath.line element.

    If you paste the code you're using, it might be easier to spot where you're going wrong.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Sunday, September 18, 2011 7:25 AM
    Moderator

All replies

  • I've managed to do all but one thing: the map automatically pans and zooms to the route returned, although I have set it such that the route isn't shown. How do I prevent this automatic panning and zooming in v7?
    Sunday, September 18, 2011 2:23 AM
  • I'm not sure how you're adding the routeline to the map, but Bing Maps shouldn't automatically set a best view every time an entity is added to the map.

    To snap a point to the nearest (routable) road in v7, you should call the REST route service, supplying the point as both the start and end point of the route. Then, in the route callback, retrieve the first coordinate in the result.resourceSets[0].resources[0].routePath.line element.

    If you paste the code you're using, it might be easier to spot where you're going wrong.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Sunday, September 18, 2011 7:25 AM
    Moderator