Search code examples
androidgoogle-maps-api-2gdirections

GDirections from Google API v2


I am trying to use the Gdirections to make my map look a little nicer. Currently I can place all the waypoints on the map, but when I try to create a GDirection object to pass the waypoints into the query I get "GDirections cannot be resolved to a type". I am trying to follow the Constructor on https://developers.google.com/maps/documentation/javascript/v2/reference#GDirections but it doesn't seem to work. The line from my code giving errors is as follows:

GDirections direc = new GDirections(map);

I thought maybe I was not importing the required files, but I don't know what else to add. Currently I am adding

import android.graphics.Point;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Display;
import android.view.Menu;

import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;

Hopefully I am overlooking something simple. Thank you for your help!


Solution

  • GDirections is part of the Google Maps JavaScript API V2. It is not available in native Android apps (using the Maps v2 API for Android).

    The Google Directions API is a REST based API that you can use in Android for displaying directions.

    You can use the Google HTTP Client Library for Java to access the Directions API on an Android device.