Solved

AS3 step by step direction by google map

Posted on 2011-09-23
6
316 Views
Last Modified: 2012-05-12
Hi,

I was wondering if I can get a tip of how to have a step by step direction from google map. In my app, I can display the direction on the map but I also want to have the written step by step direction on the side.
0
Comment
Question by:Angha110
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 36713606
When you will get responce from Google API you can get Route object
Here is an example:

function onDirectionsLoaded(event:DirectionsEvent):void
{
      var returnedDirection:Directions = event.directions as Directions;
      
      var route:Route = dir.getRoute(0);
      for(var i:uint = 0; i < route.numSteps; i++){
            var step:Step = route.getStep(i);
            trace(step.descriptionHtml + " - " + step.distanceHtml + ", " + step.durationHtml);
      }
}
0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 36713608
function onDirectionsLoaded(event:DirectionsEvent):void
{
      var dir:Directions = event.directions as Directions;
      
      var route:Route = dir.getRoute(0);
      for(var i:uint = 0; i < route.numSteps; i++){
            var step:Step = route.getStep(i);
            trace(step.descriptionHtml + " - " + step.distanceHtml + ", " + step.durationHtml);
      }
}
0
 

Author Closing Comment

by:Angha110
ID: 36717795
Thank you
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Angha110
ID: 36718143
One more question,
How do I set the dynamic text to properly display the step by step.

Here is what I get from a imaginary address:

Head <b>northeast</b> on <b>Flying Cloud Dr</b> toward <b>Singletree Ln</b> - 0.2&nbsp;mi, 20 secs
Turn right onto <b>W 78th St</b> - 1.4&nbsp;mi, 3 mins
<b>W 78th St</b> turns right and becomes <b>Town Line Ave</b><div class="google_impnote">This road is closed until Oct 31</div> - 0.3&nbsp;mi, 43 secs
Turn left onto <b>US-169 N</b> - 8.3&nbsp;mi, 8 mins
Take the exit onto <b>I-394 W</b> - 1.6&nbsp;mi, 3 mins
Take exit <b>1C</b> for <b>Ridgedale Dr</b> - 0.2&nbsp;mi, 27 secs
Turn right onto <b>Ridgedale Dr</b> - 259&nbsp;ft, 5 secs
Turn left onto <b>N Frontage Rd/<wbr/>Wayzata Blvd</b><div class="google_note">Destination will be on the right</div> - 0.4&nbsp;mi, 1 min
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36718243
0
 

Author Comment

by:Angha110
ID: 36718433
This is great, thank you again for the great help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question