| Author |
Message |
tv_sathish Developer
Joined: 09 Jan 2008 Posts: 29
|
Posted: Wed Mar 05, 2008 6:32 pm Post subject: How to use Driving Directions in mc5 release? |
|
|
Hi all,
I tried using this DrivngDirections project but I am not able to see any route in the map? Why is it so? Also is there a default key to zoom the map? If I click the map, somtimes it shows the "Pin" symbol but I am not able to figure when it shows that symbol and on what basis? How can I see the driving directions on the map? I am able to see the time and distance indicators on the left after some time, though.
I saw somewhere else (in some example) of mc5 release, showing Driving Directions like instructions (Turn left, go straight 50 miles etc.)? Is there any new API that does this? Please help me how to achieve this?
How to use DrivingDirection.getFormattedDistance and DrivingDirection.getFormattedTime to get the actual distance and time (values, integer or date values), by say, parsing the string output returned by these methods? What are the default formats for these 2 meaurements? In this project, "Time : " in DrivingDirection.getFormattedTime is replaced with "". That means there is a default format for these two? what is that?
Thanks and regards,
TVP
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
Posted: Wed Mar 05, 2008 8:18 pm Post subject: Re: How to use Driving Directions in mc5 release? |
|
|
Hello tv_sathish,
| tv_sathish wrote: | Hi all,
I tried using this DrivngDirections project but I am not able to see any route in the map? Why is it so? Also is there a default key to zoom the map? If I click the map, somtimes it shows the "Pin" symbol but I am not able to figure when it shows that symbol and on what basis? How can I see the driving directions on the map? I am able to see the time and distance indicators on the left after some time, though. |
If you copy-pasted the code, it will work. (You may have to pan the Map once, to get the first redraw done)
Since m5 there are so called LongClickListener, which i.e. the MapView (and the Browser) use. I also took me some crazy tries to figure out how to get the zoomer visible ^^
| tv_sathish wrote: | | I saw somewhere else (in some example) of mc5 release, showing Driving Directions like instructions (Turn left, go straight 50 miles etc.)? Is there any new API that does this? Please help me how to achieve this? |
Was it this you were seeing: http://andnav.anddev.org/
The Driving-Directions also provide the turns to make. (I think it was sth like ".getTurns()").
| tv_sathish wrote: | | How to use DrivingDirection.getFormattedDistance and DrivingDirection.getFormattedTime to get the actual distance and time (values, integer or date values), by say, parsing the string output returned by these methods? What are the default formats for these 2 meaurements? In this project, "Time : " in DrivingDirection.getFormattedTime is replaced with "". That means there is a default format for these two? what is that? |
There currently is no other way to get these values directly.
I calculate the lenght of the route, by calculating the lenght of each route-segment.
For time I have to make approximations.
Regards,
plusminus
_________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
tv_sathish Developer
Joined: 09 Jan 2008 Posts: 29
|
Posted: Thu Mar 06, 2008 6:36 pm Post subject: DrivingDirections on map related issuee...(contd.) |
|
|
Hi Plusminus,
Thanks a lot for your help. I tried getTurns(). What I want to know from you is whether getTurns() also returns normal directions (i.e. walking straight paths like "Walk 50 miles down XXX highway", etc., and not just turning instructions as it name suggests)? To me it appears to give all instructions (even non-turns), but I just thought of getting confirmed with you? Can you confirm this?
1. My driving directions are still not visible on the map in the project mentioned in this topic. I am attaching the
JPEG, it is not showing any further than that (as I told you, the PIN mark and the distance and time values on
the left). As I have not changed anything in your code, I am not sending code portions, but if you want to
verify, do let me know and I will send them. I am not seeing any directions. What is the problem?
2. How to add vertical scrollbars to your ListView?
3. How to set the position of the dialog? How to change background color/text color of dialog and ListView (not very urgent, but
interested to know)?
Thanks and regards,
TVP (tv_sathish) (you can refer me by TVP - short name for typing convenience )
| Description: |
|
| Filesize: |
57.63 KB |
| Viewed: |
1224 Time(s) |

|
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
Posted: Fri Mar 07, 2008 12:16 am Post subject: |
|
|
Hello tvp ,
yes, it returns only Turns.
1. Did you debug Does the Path get filled and canvas.drawPath(...,...); get called
2/3. Is there a ListView in this app
Regards,
plusminus
_________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
tv_sathish Developer
Joined: 09 Jan 2008 Posts: 29
|
Posted: Fri Mar 07, 2008 7:27 pm Post subject: Issues (contd.).. |
|
|
Hi Plusminus,
The DrivingDirections.getTurns does show something like "Head south toward..", "Merge onto ...", Take the State Hwy..."". Are you sure the Turns gives you only Turns related instructions? If so, can you share with me how to then get the directions for all the other instructions (i.e. all non-turn instructions)?
For the Overlay problem, the "draw" method's first line itself is not reached by the debugger, but I see the PIN and the distance/time values? How this is possible? could this be due to network slowness? Can you give me a screenshot of how the path will show if everything works well?
I have only a Dialog and TextView and I want to add scroll for the TextView and to be able to set Font color/Background color etc.? Do you know how to set scroll for TextView and how to set the Font color(background color I tried and it worked) for any View?
Do you know how to set some option with Spinner (not getting, but setting programmatically)? How to also not react to spinner clicks? I tried spinner.setOnItemSelectedListener(null), but it didn't work?
Why does the DrivingDirections fetch more than 4-5 seconds across a Dial-up network? Will Android team who test our contest entries be using a better network and can we assume that amount of network speed and write apps that use DrivingDirections?
Finally, I have a problem where I want to show something in a TextView and then after some time, say a few seconds, show a dialog. I have written the code like this:
| Code: | mResultsArea.requestFocus();
try {
Thread.sleep(2000);
} catch(Exception e) {}
showDialog(); |
but what happens is that the TextView box itself gets filled only after 2 seconds and the dialog pops up immediately with it, quite not what I wanted. What could be the problem and how to solve it?
Thanks and regards,
TVP
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
Posted: Sun Mar 09, 2008 1:41 pm Post subject: Re: Issues (contd.).. |
|
|
Hello tvp,
| tv_sathish wrote: | Hi Plusminus,
The DrivingDirections.getTurns does show something like "Head south toward..", "Merge onto ...", Take the State Hwy..."". Are you sure the Turns gives you only Turns related instructions? |
Yes.
| tv_sathish wrote: | | If so, can you share with me how to then get the directions for all the other instructions (i.e. all non-turn instructions)? |
That is not provided by the DrivingDirections. (maybe in the future ??)
| tv_sathish wrote: | | For the Overlay problem, the "draw" method's first line itself is not reached by the debugger, but I see the PIN and the distance/time values? How this is possible? |
Sounds really strange.
| tv_sathish wrote: | | could this be due to network slowness? |
No.
| tv_sathish wrote: | Can you give me a screenshot of how the path will show if everything works well?
See page 1 of this topic. |
| tv_sathish wrote: | | I have only a Dialog and TextView and I want to add scroll for the TextView and to be able to set Font color/Background color etc.? Do you know how to set scroll for TextView and how to set the Font color(background color I tried and it worked) for any View? |
Search for ScrollView
This topic is not the right place for such a question!
| tv_sathish wrote: | | Do you know how to set some option with Spinner (not getting, but setting programmatically)? How to also not react to spinner clicks? I tried spinner.setOnItemSelectedListener(null), but it didn't work? |
This topic is not the right place for such a question!
| tv_sathish wrote: | | Why does the DrivingDirections fetch more than 4-5 seconds across a Dial-up network? Will Android team who test our contest entries be using a better network and can we assume that amount of network speed and write apps that use DrivingDirections? |
I don't know why it takes ""so long"" but expect at least the same delay on an actual device You can simulate such delay and speeds in the DDMS-View.
| tv_sathish wrote: | Finally, I have a problem where I want to show something in a TextView and then after some time, say a few seconds, show a dialog. I have written the code like this:
| Code: | mResultsArea.requestFocus();
try {
Thread.sleep(2000);
} catch(Exception e) {}
showDialog(); |
but what happens is that the TextView box itself gets filled only after 2 seconds and the dialog pops up immediately with it, quite not what I wanted. What could be the problem and how to solve it? |
Remember: Do not send the UI-Thread to sleep Why Because the user gets pissed of
Strange, perhaps add a Log.e to the catch-block and check if any Exception gets thrown.
Regards,
plusminus
_________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
tv_sathish Developer
Joined: 09 Jan 2008 Posts: 29
|
Posted: Mon Mar 10, 2008 2:41 pm Post subject: Regarding DrivingDirections...(contd.) |
|
|
Hi Plusminus,
Would you be able to share how you have managed to show non-Turn instructions in your project? I see that a loop through dd.getFeature(<>) returns all objects as Turn objects. How are u managing to show other non-Turn directions?
If sleeping within main thread isn't advisable, is there a method by which I can show some View after a small delay after displaying current view?
Basically I didn't want to start another post on Scrolling in case nobody replied. Also I felt it may be inconvenient for you too to open many posts and reply. That's why I added the doubts there itself. Anyway I shall follow what u said. But bear with me this time, I have one more just one-liner question that may not be suitable for this topic - how to receive all large amounts of data (I saw related posts but could not figure out how to do this) - through the android.net.RequestQueue mechanism? Data from server is cut halfway (after some <6K bytes) - full HTTP response not coming?
Thanks and regards
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
|
| Back to top |
|
 |
jdoubleu Freshman
Joined: 01 Mar 2008 Posts: 3 Location: New York City
|
Posted: Mon Mar 24, 2008 3:31 am Post subject: |
|
|
plusminus,
Thanks for the helpful tutorial.
I am having the same experience as TVP. I am unable to see the path when the app loads, and I can see all of north america. If i drag on the map a bit, then i am able to see the 2 pushpins drawn right on top of each other over the san francisco bay area.
I added some stmts into the onCreate() method to zoom/center to one of the path endpoints, and i am now able to see the path better when the app first loads.
ctrl.zoomTo(9);
ctrl.centerMapTo(new Point(37423157, -122085008), true);
I am assuming that these calls would be necessary no? I mean to say that I'm surprised that it would work without them. Am I correct in my thinking?
One more question. Is there a way to programmatically "wiggle" the map so as to force the map to draw the route?
Thanks again,
jw
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
|
| Back to top |
|
 |
Mick Freshman
Joined: 24 Mar 2008 Posts: 6 Location: France
|
Posted: Mon Mar 24, 2008 5:00 pm Post subject: |
|
|
Hello PlusMinus.
First of all, thanks a lot for helping us in discovering the android programming.
I want to improve this example (pretty good) by adding an animation along the route. I tried to do it like in the google website : http://code.google.com/android/reference/android/view/animation/package-descr.html but with a ImageButton to stop the Button(the car), but I think there is problem with the overlay and my button doesn't appear on my map.
Nevertheless I know that your current work on AndNav must be kept secret, but if you have an idea to help me, i will be very happy .
Thanks a lot for all you do for the community.
|
|
| Back to top |
|
 |
jdoubleu Freshman
Joined: 01 Mar 2008 Posts: 3 Location: New York City
|
Posted: Mon Mar 24, 2008 6:03 pm Post subject: |
|
|
yes, panning causes the map to redraw, but in my case, the user will be confused if the directions don't just show up automatically.
Yes, by "wiggle" I meant a hack to programmatically pan a tiny bit to force the redraw, sounds like I should try that invalidate method tho. Thanks for the tip!
jw
|
|
| Back to top |
|
 |
inter Junior Developer
Joined: 21 Feb 2008 Posts: 23
|
Posted: Mon Mar 24, 2008 7:20 pm Post subject: |
|
|
Hi everyone. The program above to me is not work .I'm using m5_rc15 .Why that ? the screen not see the PIN_END ,PIN_START ,not see the route path . I don't know when the method draw is called .Please someone can help me
Thanks
Regard
|
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2067 Location: Germany
|
Posted: Mon Mar 24, 2008 7:23 pm Post subject: |
|
|
Hello inter,
you see I attached 2 versions to the very first post of this topic (one for m3 and one for m5).
The m5 version is the 1:1 copy of my code, which is working.
draw() of the Overlay gets called everytime the map needs invalidation, i.e. when it was panned, zoomed, ...
Regards,
plusminus
_________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
inter Junior Developer
Joined: 21 Feb 2008 Posts: 23
|
Posted: Tue Mar 25, 2008 12:10 pm Post subject: |
|
|
Thank minus for reply quickly
When i debug the program above .I see that the method draw is called first when the program launch .But when i click the button "Show me the route " i think it will call the method draw ,but it doesn't call .Why that . how to call the method draw when i click the button "Show me the route"
i copied 1-1 your program ,but it's not work .
help me
thanks
regard
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
© 2007, Android Development Community
All rights reserved.
Powered by phpBB.
|