小编Muh*_*azi的帖子

Google Map Android API V2中两个位置之间的旅行时间

如何在Google Map Android API V2中显示两个位置之间的旅行时间,在我的程序中我使用JSONParse来显示行车距离,但是我无法显示显示行程时间,这个我做的示例程序:DirectionActivity.java

public class DirectionActivity extends FragmentActivity implements OnMyLocationChangeListener{

private LatLng          start;
private LatLng          end;
private String          nama;
private final String    URL = "http://maps.googleapis.com/maps/api/directions/json?";
private GoogleMap       map;
private JSONHelper      json;
private ProgressDialog  pDialog;
private List<LatLng>    listDirections;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction);
    json = new JSONHelper();
    setupMapIfNeeded();

    Bundle b = getIntent().getExtras();
    if (b != null)
    {
        start = new LatLng(b.getDouble(MainActivity.KEY_LAT_ASAL), b.getDouble(MainActivity.KEY_LNG_ASAL));
        end = new LatLng(b.getDouble(MainActivity.KEY_LAT_TUJUAN), b.getDouble(MainActivity.KEY_LNG_TUJUAN));
        nama = b.getString(MainActivity.KEY_NAMA);
    }

    new AsyncTaskDirection().execute();
}

private void …
Run Code Online (Sandbox Code Playgroud)

android json location google-maps google-maps-android-api-2

5
推荐指数
1
解决办法
1万
查看次数