Virtual Earth API: Simple Multipoint Routing Example

Keith Kinnan's Weblog
01-04-2008, 09:27 AM
<P>One of the new features of the Virtual Earth API is multipoint routing.&nbsp; Now, you can specify multiple points on a route and get directions to/from them.&nbsp; The new <STRONG>GetDirections </STRONG>call on the VEMap makes it easy to do this.</P>
<P>For example, here's a simple code sample which shows how to get driving directions from San Jose to San Francisco. The first parameter to the GetDirections call is an array of locations.&nbsp; You can pass string names or latitude, longitude pairs of VELatLong objects.</P>
<BLOCKQUOTE>
<P>var locations = new Array();<BR>locations.push("San Jose, California");<BR>locations.push("San Francisco, California");<BR>map.GetDirections(locations);</P></BLOCKQUOTE>
<P>For the complete code sample see:</P>
<BLOCKQUOTE>
<P><A href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample01.html" mce_href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample01.html">Virtual Earth API Simple Route Example</A></P>
<P><A href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample01.html"><IMG style="WIDTH: 400px; HEIGHT: 300px" height=300 src="http://krkinnan.members.winisp.net/samples/v6/route/ve6route01.jpg" width=400 border=0 mce_src="http://krkinnan.members.winisp.net/samples/v6/route/ve6route01.jpg"></A></P></BLOCKQUOTE>
<P>Now, let's say on the way to San Francisco, you want to make a stop in Santa Clara and Palo Alto.&nbsp; All you have to do is put those locations in the locations array in the order you want to visit them, and then pass them to GetDirections.</P>
<BLOCKQUOTE>
<P>var locations = new Array();<BR>locations.push("San Jose, California");<BR>locations.push("Santa Clara, California");<BR>locations.push("Palo Alto, California");<BR>locations.push("San Francisco, California");<BR>map.GetDirections(locations);</P></BLOCKQUOTE>
<P>The route will then pass through the desired locations on the way to the destination.</P>
<P mce_keep="true">For the complete code sample see:</P>
<BLOCKQUOTE>
<P><A href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample02.html" mce_href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample02.html">Virtual Earth API Simple Multipoint Route Example</A></P>
<P><A href="http://krkinnan.members.winisp.net/samples/v6/route/v6routesample02.html"><IMG style="WIDTH: 400px; HEIGHT: 300px" height=300 src="http://krkinnan.members.winisp.net/samples/v6/route/ve6route02.jpg" width=400 border=0 mce_src="http://krkinnan.members.winisp.net/samples/v6/route/ve6route02.jpg"></A></P></BLOCKQUOTE>
<P>In a future post I will show more details on how to customize the route even more with the GetDirections call.</P><img src="http://blogs.msdn.com/aggbug.aspx?PostID=5619943" width="1" height="1">

More... (http://blogs.msdn.com/keithkin/archive/2007/10/23/virtual-earth-api-simple-multipoint-routing-example.aspx)

 
Web mp2kmag.com
mapforums.com