相关疑难解决方法(0)

在GoogleMap SupportMapFragment上绘制2个GeoPoints之间的行车路线

这是一个棘手的问题,一直在敲我的头一天,请帮忙.

我使用Google Maps Apis来获取我提供的2个GeoPoints之间的最短行驶距离及其路线,点等,请参阅下面的代码

private JSONObject GetDistance(String src, String dest) throws Exception
{
    StringBuilder urlString = new StringBuilder();
    urlString.append("http://maps.googleapis.com/maps/api/directions/json?");
    urlString.append("origin=");// from
    urlString.append(src);
    urlString.append("&destination=");// to
    urlString.append(dest);
    urlString.append("&mode=driving&sensor=true&units=imperial");

    // get the JSON And parse it to get the directions data.
    HttpURLConnection urlConnection = null;
    URL url = null;

    url = new URL(urlString.toString());
    urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestMethod("GET");
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.connect();

    InputStream inStream = urlConnection.getInputStream();
    BufferedReader bReader = new BufferedReader(new InputStreamReader(inStream));

    String temp, response = "";
    while ((temp = bReader.readLine()) != null)
    { …
Run Code Online (Sandbox Code Playgroud)

android google-maps android-maps android-mapview google-maps-android-api-2

2
推荐指数
1
解决办法
7331
查看次数