-
Notifications
You must be signed in to change notification settings - Fork 27
Installation
Your Goal: You already have an application that uses GoogleMap and you want to diaplay Direction on it. Your installation: '''JAVA //Download the project, import it in Eclipse. //Doesn't compile. try{ //Ok, this project needs to know the GoogleMap object embedded in the GooglePlayService Api. //So as you did for your own project link google play service to this project. }catch(InstallException){ //1)Import the google_play_service //In Eclipse, do new\other\AndroidProject... then select $user\androidsdk\extras\google\libproject\google_play_service_lib //Compile this new project //2)Link it to the GDirectionsApiUtils //GDirectionsApiUtils->BuildPath, Select Android and then add the google_play_service_lib as a librairy } finally{//compile GDirectionsApiUtils.} ` In your own Project, import it as a librairy, copy/paste the gdirectionsapiutils.jar from GDirectionsApiUtils/bin/ to your libs project. As usual, in the BuildPath of your project:
- link the eclipse project to your project
- add the GDirectionsApiUtils as a librairy in the android part (still in the build path).
Ok, compile, and then use it to retrieve direction between two points. First ask for the direction using getDirection and then when the stuff is built, we call the method onDirectionLoaded giving you the Directions your were looking for:
public class MainActivity extends ActionBarActivity implements DCACallBack{
/**
* Get the Google Direction between mDevice location and the touched location using the Walk
* @param point
*/
private void getDirections(LatLng point) {
GDirectionsApiUtils.getDirection(this, mDeviceLatlong, point, GDirectionsApiUtils.MODE_WALKING);
}/*
* (non-Javadoc)
*
* @see
* com.android2ee.formation.librairies.google.map.direction.DCACallBack#onDirectionLoaded(com
* .android2ee.formation.librairies.google.map.direction.GDirection)
*/
@Override
public void onDirectionLoaded(List<GDirection> directions) {
// Display the direction or use the DirectionsApiUtils
for(GDirection direction:directions) {
Log.e("MainActivity", "onDirectionLoaded : Draw GDirections Called with path " + directions);
GDirectionsApiUtils.drawGDirection(direction, mMap);
}
}`