| Author |
Message |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2655 Location: College Park, MD
|
Posted: Mon Apr 28, 2008 11:45 pm Post subject: Route - Improved Google Driving Directions |
|
|
Hey guys,
| License wrote: |
This source by Nicolas Gramlich is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Germany License .
Permissions beyond the scope of this license may be requested at plusminus {at} anddev {dot} org . |
some days ago I sweared to post my improved implementation of the buggy Android-included Driving-Directions.
Moving from the original DrivingDirections to my own implementation was done in just a couple of minutes. The output of the implementations are not directly the same but really similar and easily 'mappable'. Where my implementation is more reliable than the 'untransparent' Google-one which was really buggy.
This implementation is not a final one at all but is usable. Interfaces and method declarations may and probably will vary over time.
Exactly the same code you will find in the attached zip is what I use in my AndNav!-Application.
What you need is a GOOGLE APPID Do a quick GoogleSearch on how to get one. Then enter it to the Constants.java - Interface.
For now I'll attach a complete sample-project. Description follows when I have more time
This is all you have to do:
| Java: | /* This line is all you need =) */
Route r = RouteFactory.create(Nationality.USA,
"37.544694,-122.360356", // From: "San Francisco"
"40.706384,-74.012672", // To: "New York - Broadway"
"39.745684,-104.998457"); // Via: "Denver" |
As a complete project, producing the following output:
you need to code:
| Java: | public class RouteSample extends Activity {
TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
tv = new TextView(this);
tv.setText("Please wait a moment...");
setContentView(tv);
new Thread(new Runnable(){
@Override
public void run() {
try {
/* This line is all you need =) */
Route r = RouteFactory.create(Nationality.USA,
"37.544694,-122.360356", // From: "San Francisco"
"40.706384,-74.012672", // To: "New York - Broadway"
"39.745684,-104.998457"); // Via: "Denver"
/* Lets read out some values... */
StringBuilder sb = new StringBuilder();
sb.append("Total Distance (meters): ").append(r.getDistanceMeters()).append("\n");
sb.append("Total Time (seconds): ").append(r.getDurationSeconds()).append("\n\n");
sb.append("First subroute: Locationname: ");
sb.append(r.getSubRoutes()[0].getEnd().getAdvancedAddress().getLocality()).append("\n");
sb.append("Lenght of first subroute (meters): ").append(r.getSubRoutes()[0].getLengthMeters()).append("\n");
sb.append("Overall Points in Polyline: ").append(r.getPolyLine().length);
/* Show the values on the TextView. */
setTextOnUIThread(tv, sb.toString());
} catch (Exception e) {
/* Oops something went wrong... */
setTextOnUIThread(tv, "Error: " + e.getMessage());
}
}
}).start();
}
/** Simple helper function. */
private void setTextOnUIThread(final TextView t, final String s){
runOnUIThread(new Runnable(){
@Override
public void run() {
t.setText(s);
}
});
}
} |
| License wrote: |
This source by Nicolas Gramlich is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Germany License .
Permissions beyond the scope of this license may be requested at plusminus {at} anddev {dot} org . |
Regards,
plusminus
| Description: |
|
 Download |
| Filename: |
RouteSample.zip |
| Filesize: |
200.41 KB |
| Downloaded: |
952 Time(s) |
_________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
|
|
 |
brijeshthakur Junior Developer

Joined: 23 Jul 2008 Posts: 12 Location: Banglore,India
|
Posted: Thu Jul 24, 2008 10:08 am Post subject: Operation Time-Out Error |
|
|
Hi PlusMinus.
Your DrivingDirection application giving me "Operation time-out error".
The LogCat Shows the Below Information
INFO/Connecting...(611):
Connecting to.."http://maps.google.com/maps/nav?hl=US&gl=US&output=js&oe=utf8&q=from%3A37.788081%2C-122.415847+to%3A39.766325%2C+-104.989471+to%3A40.751418%2C-74.009399&key=ABQIAAAAQQcZviIzmIqVxEaMT12eqxT4XTUArVw0hfaJt-dPnDdoJ_2yihSOjsppgL4ku_kEd5DDd3kEV_K2AQ"
by the way. I got Google APPID from http://code.google.com/apis/maps/signup.html.
by giving "http://maps.google.com/map/nav" in the URL textbox.
Do Let me know where I am wrong.
Thanks in Advance.
Regards,
Brijesh.
|
|
| Back to top |
|
 |
stunti Once Poster

Joined: 08 Oct 2008 Posts: 1
|
Posted: Wed Oct 08, 2008 11:52 am Post subject: |
|
|
Hi,
Is there a way to get this library working again ?
MapPoint doesn't exists anymore.
Or is there another way to get driving direction?
Thanks a lot.
|
|
| Back to top |
|
 |
gustavo Junior Developer

Joined: 02 Mar 2008 Posts: 12
|
Posted: Fri Nov 14, 2008 6:01 pm Post subject: I canīt make it run |
|
|
| Can you tell me how can I get com.google.googlenav package? My 1.0_r1 sdk version can't find it.
|
|
| Back to top |
|
 |
zak Freshman

Joined: 23 Sep 2008 Posts: 8
|
Posted: Fri Jan 09, 2009 5:30 pm Post subject: Draw path on the map |
|
|
hi plusminus! i have a question for you... i tried you code "RouteSample" but this don't allow me to draw the path on the map. it doesn't follow the routes but it just draws a straight line from "point A" to "point B" .
how can i solve it? is there another way?
thanks!
| Description: |
|
| Filesize: |
61.2 KB |
| Viewed: |
6224 Time(s) |

|
|
|
| Back to top |
|
 |
yorgosg Developer

Joined: 30 Jan 2008 Posts: 32
|
Posted: Wed Jan 21, 2009 4:46 pm Post subject: Re: Operation Time-Out Error |
|
|
| brijeshthakur wrote: | Hi PlusMinus.
Your DrivingDirection application giving me "Operation time-out error".
The LogCat Shows the Below Information
INFO/Connecting...(611):
Connecting to.."http://maps.google.com/maps/nav?hl=US&gl=US&output=js&oe=utf8&q=from%3A37.788081%2C-122.415847+to%3A39.766325%2C+-104.989471+to%3A40.751418%2C-74.009399&key=ABQIAAAAQQcZviIzmIqVxEaMT12eqxT4XTUArVw0hfaJt-dPnDdoJ_2yihSOjsppgL4ku_kEd5DDd3kEV_K2AQ"
by the way. I got Google APPID from http://code.google.com/apis/maps/signup.html.
by giving "http://maps.google.com/map/nav" in the URL textbox.
Do Let me know where I am wrong.
Thanks in Advance.
Regards,
Brijesh. |
can someone post the process of acquiring a google app id?
the above url you posted doesnt work (http://code.google.com/apis/maps/signup.html), I have managed to login with my gmail credentials to a google apps portal that has loads of info all over the place, all very confusing
is there an easier way of getting an app id?
can anyone help?
|
|
| Back to top |
|
 |
|
|
 |
Tushaar Freshman

Joined: 27 Feb 2009 Posts: 2 Location: pune,India
|
Posted: Fri Feb 27, 2009 4:24 pm Post subject: |
|
|
hey hi +- .. i have gone thru ur posts .. and these are really helped me a lot .. wel thnx a lot ..
I want to do same stuff of driving directions but i am using SDK 1.0 .,. and googlenav API not supported in SDK 1.0
can u help me in this matter plz ..
thnx in advance
|
|
| Back to top |
|
 |
linkmaster_6 Developer

Joined: 16 Oct 2008 Posts: 48
|
Posted: Mon Mar 09, 2009 11:02 pm Post subject: |
|
|
| So is this made for sdk 1.0? or is that a no? is there no easy way to construct a path?
|
|
| Back to top |
|
 |
ashish Developer

Joined: 20 Feb 2009 Posts: 46
|
Posted: Thu Mar 12, 2009 10:07 am Post subject: |
|
|
hello plus/minus.your tutorial are excellent but problem is that now every one is using sdk1.0 so,many api's are not supported.so please in future,post the tutorial for sdk1.0 only.
In your driving direction tutorial you have used "import com.google.googlenav.DrivingDirection;" package which is not there in sdk1.0 so,do you know any other equivalent API..please let me know...
thanks in advance...............
|
|
| Back to top |
|
 |
csie-tw Freshman

Joined: 21 Jun 2009 Posts: 2
|
Posted: Sun Jun 21, 2009 11:35 am Post subject: |
|
|
| linkmaster_6 wrote: | | So is this made for sdk 1.0? or is that a no? is there no easy way to construct a path? |
DrivingDirection can not be used anymore since SDK 1.1.
However, I found a method to implement the Driving Direction function
without the package com.google.googlenav.DrivingDirection.
http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
|
|
| Back to top |
|
 |
xenon Freshman

Joined: 11 Jun 2009 Posts: 2
|
Posted: Thu Jun 25, 2009 2:33 pm Post subject: |
|
|
| csie-tw wrote: | | linkmaster_6 wrote: | | So is this made for sdk 1.0? or is that a no? is there no easy way to construct a path? |
DrivingDirection can not be used anymore since SDK 1.1.
However, I found a method to implement the Driving Direction function
without the package com.google.googlenav.DrivingDirection.
http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
|
Looks good, but is there any way to get the source of this?
It's kinda hard to read on the website and some lines are cut.
|
|
| Back to top |
|
 |
zpk1234 Junior Developer

Joined: 27 Jun 2009 Posts: 14
|
|
| Back to top |
|
 |
arvind Freshman

Joined: 23 Jun 2009 Posts: 7 Location: Mumbai,India
|
Posted: Thu Jul 02, 2009 10:40 am Post subject: |
|
|
zpk1234 .... enable your browser / firewall to open sites of all languages.....
csie-tw ... your blog was very helpful thank you....
I have a Map with placemarks as bitmaps on it using overlay
Could anyone please tell me if there is any way i can handle the event of clicking a bitmap on the MapView...
Forgive me, my english little poor....
let know me if u understand my question....
|
|
| Back to top |
|
 |
zpk1234 Junior Developer

Joined: 27 Jun 2009 Posts: 14
|
Posted: Thu Jul 02, 2009 2:49 pm Post subject: |
|
|
| arvind wrote: | zpk1234 .... enable your browser / firewall to open sites of all languages.....
csie-tw ... your blog was very helpful thank you....
I have a Map with placemarks as bitmaps on it using overlay
Could anyone please tell me if there is any way i can handle the event of clicking a bitmap on the MapView...
Forgive me, my english little poor....
let know me if u understand my question.... |
it is surprised that the mapview cann't receive the click message, and MapActivity is no response in onActivityResult when another Activity is stop too, i have no idea for this!
|
|
| Back to top |
|
 |
|