Not to be outdone by the latest beta releases from the Services Team the SDK team have a brand new Directions module for the Actionscript/Flex SDK that uses the new Directions Service already in production.
ActionScript SDK Updates
Available on the Developer Network Beta page.
- Completely new Directions module
- There is a new Directions.swc which replaces all the routing functionality previously found in the AdvantageApi.swc - this is a complete overhaul and upgrade to the object model and how you use it - it is now MUCH MUCH simpler and saner - and smaller!
- Simplified Routing Function
- Create a route object, pass in your locations, provide your map object, and watch the route ribbon and stop-icons appear on the map automagically. Provide an event handler to receive the directions narrative. Done!.
If you are a power-user type, you can dive under the covers to provide all the different options available from the underlying Directions Service or customize the look and feel of the route ribbon and stop-icons that are added to the map.
The code would look something like this:
this.myMap = new TileMap("YOUR_KEY_HERE");
//create an array of locations
var arrLocations:Array = new Array();
arrLocations = ['Lancaster, PA', 'York, PA'];
//create the Directions object, hand in map object and locations array
this.dir = new Directions(myMap, arrLocations);
//Success Listener - handle the narrative here
//get the route
- Draggable Routes!
- If you want your users to be able to drag the route, then on the directions object, just add
dir.ribbonIsDraggable = true;before asking for the route - at the end of each drag, your directions success event handler is called again so you can handle the updated narrative - that's it. done!
- Optimized Routing
- With Optimized Routing, all of the stops between the first and last are reordered for the shortest overall distance or drive time, giving the most efficient path for visiting several locations on a single journey. Instead of calling the
dir.route();function, use the
dir.optimizedRoute();to get an optimized route.
- Route Matrix
- A Route Matrix request in the Directions Web Service will return a quick and easy calculation of the distances and drive times between a bunch of points. Nothing gets added to the map, the results are returned to your success listener, but you set up the directions object in the same way as a regular route and then call, for example,
Work continues as we revitalize, enhance, upgrade, streamline, and simplify our web services and SDKs. It remains our goal to roll out each project to beta at the end of every sprint if possible (some things take more than one sprint). I hope to be back here soon with a nother blog post announcing more cool things