Android Google Map найти расстояние - PullRequest
3 голосов
/ 23 июня 2011

Я пытаюсь найти расстояние между двумя точками. У меня есть долготы и широты, и я могу рассчитать евклидово расстояние. Но я хочу найти дорожное расстояние. Я имею в виду, я хочу вычислить расстояние от дороги, по которой я иду, когда иду к месту назначения от источника. В таком случае как рассчитать это?

Ответы [ 5 ]

7 голосов
/ 23 июня 2011

Самый простой способ - использовать API Google Directions для получения маршрутов, это дает вам список всех точек на маршруте (и общее расстояние).

Проверьте: http://code.google.com/apis/maps/documentation/directions/

Если вы не уверены, как это сделать, дайте мне знать, и я опубликую для вас код, который получит указания от Google и извлечет данные, которые вынужно.

ОБНОВЛЕНИЕ - КОД ЗАПРОШЕННЫЙ

private void GetDistance(GeoPoint src, GeoPoint dest) {

    StringBuilder urlString = new StringBuilder();
    urlString.append("http://maps.googleapis.com/maps/api/directions/json?");
    urlString.append("origin=");//from
    urlString.append( Double.toString((double)src.getLatitudeE6() / 1E6));
    urlString.append(",");
    urlString.append( Double.toString((double)src.getLongitudeE6() / 1E6));
    urlString.append("&destination=");//to
    urlString.append( Double.toString((double)dest.getLatitudeE6() / 1E6));
    urlString.append(",");
    urlString.append( Double.toString((double)dest.getLongitudeE6() / 1E6));
    urlString.append("&mode=walking&sensor=true");
    Log.d("xxx","URL="+urlString.toString());

    // 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){
        //Parse data
        response += temp;
    }
    //Close the reader, stream & connection
    bReader.close();
    inStream.close();
    urlConnection.disconnect();

    //Sortout JSONresponse 
    JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
    JSONArray array = object.getJSONArray("routes");
        //Log.d("JSON","array: "+array.toString());

    //Routes is a combination of objects and arrays
    JSONObject routes = array.getJSONObject(0);
        //Log.d("JSON","routes: "+routes.toString());

    String summary = routes.getString("summary");
        //Log.d("JSON","summary: "+summary);

    JSONArray legs = routes.getJSONArray("legs");
        //Log.d("JSON","legs: "+legs.toString());

    JSONObject steps = legs.getJSONObject(0);
            //Log.d("JSON","steps: "+steps.toString());

    JSONObject distance = steps.getJSONObject("distance");
        //Log.d("JSON","distance: "+distance.toString());

            String sDistance = distance.getString("text");
            int iDistance = distance.getInt("value");

}

Это вернет расстояние между двумя точками, вы можете изменить функцию, чтобы она возвращалась как строка или как целое число, просто вернителибо sDistance, либо iDistance.

Надеюсь, это поможет вам, дайте мне знать, если вам нужна дополнительная помощь.

5 голосов
/ 23 июня 2011

Используйте API матрицы расстояний Google Maps http://code.google.com/apis/maps/documentation/distancematrix/.

1 голос
/ 23 июня 2011

Поскольку вы уже работаете с Google-картами, взгляните на api .

.

(Кстати, API Карт Google v3? Я предполагаю, что да)

Для пары точек широты и долготы вы можете сделать запрос о направлении движения

В API3 это будет выглядеть примерно так:

var directionsService = new google.maps.DirectionsService();
var start = from; // A Google LatLng point or an address, 
                  // see their API for further details
var end = to;     // A Google LatLng point or an address, 
                  //see their API for further details

var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};

directionsService.route(request, function (response, status) {
   //Check if status Ok
   //Distance will be in response.routes[0].legs[0].distance.text

});

Убедитесь, что статус ответа был в порядке, а затем убедитесь, что существует коллекция маршрутов. если так, то есть результат, и вы можете получить доступ к текстовому элементу "distance" через:

response.routes[0].legs[0].distance.text

Надеюсь, это поможет.

0 голосов
/ 05 января 2016

Улучшенный ответ Кенни, который работает для меня, я изменил несколько вещей в соответствии со мной.Как введен LatLng вместо геопункта.Я публикую рабочий код, который является модифицированной версией ответа Кенни.Все кредиты достаются Кенни, а не мне!

Важный момент:

Передать адрес в строковом формате.например: toronto

скопировать эту функцию:

private void GetDistance(String src, String dest) {

        String s = src.replaceAll("\\s","+");
        String d = dest.replaceAll("\\s","+");

        StringBuilder urlString = new StringBuilder();
        urlString.append("http://maps.googleapis.com/maps/api/directions/json?");
        urlString.append("origin=");
        urlString.append((s));
        urlString.append("&destination=");
        urlString.append((d));
        urlString.append("&mode=driving&sensor=true");
        Log.d("xxx", "URL=" + urlString.toString());

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

        try {
            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) {
                //Parse data
                response += temp;
            }
            //Close the reader, stream & connection
            bReader.close();
            inStream.close();
            urlConnection.disconnect();

            //Sortout JSONresponse
            JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
            JSONArray array = object.getJSONArray("routes");
            Log.d("xxx", "array: " + array.toString());

            //Routes is a combination of objects and arrays
            JSONObject routes = array.getJSONObject(0);
            Log.d("xxx", "routes: " + routes.toString());

            //String summary = routes.getString("summary");
            //Log.d("JSON","summary: "+summary);

            JSONArray legs = routes.getJSONArray("legs");
            Log.d("xxx", "legs: " + legs.toString());

            JSONObject steps = legs.getJSONObject(0);
            Log.d("JSON", "steps: " + steps.toString());

            JSONObject distance = steps.getJSONObject("distance");
            Log.d("xxx", "distance: " + distance.toString());

            String sDistance = distance.getString("text");
            int iDistance = distance.getInt("value");

            Log.d("SEE THE DIST : ", "" + sDistance + iDistance);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

Поскольку эта функция выполняет сетевые операции, мы должны использовать AsyncTask следующим образом:

private class Task extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... params) {
            GetDistance(from, to);
            return null;
        }
    }

LOG CAT:

01-05 17:01:08.657 3736-3820/in.test D/xxx: URL=http://maps.googleapis.com/maps/api/directions/json?origin=MP+Chowk+Thane+West+Thane,+Maharashtra+400080+&destination=Ghatkopar+West,+Mumbai,+Maharashtra,+India&mode=driving&sensor=true
01-05 17:01:08.687 3736-3736/in.test W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
01-05 17:01:08.687 3736-3736/in.test W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
01-05 17:01:08.797 3736-3778/in.test V/RenderScript: Application requested CPU execution
01-05 17:01:08.807 3736-3778/in.test V/RenderScript: 0xb97768c0 Launching thread(s), CPUs 4
01-05 17:01:09.097 3736-3820/in.test D/xxx: array: [{"bounds":{"northeast":{"lat":19.1885561,"lng":72.9686183},"southwest":{"lat":19.0842303,"lng":72.9075409}},"copyrights":"Map data ©2016 Google","legs":[{"distance":{"text":"15.8 km","value":15818},"duration":{"text":"26 mins","value":1562},"end_address":"Ghatkopar West, Mumbai, Maharashtra, India","end_location":{"lat":19.0908134,"lng":72.9076817},"start_address":"MP Chowk, Thane West, Thane, Maharashtra 400080, India","start_location":{"lat":19.1855772,"lng":72.9556247},"steps":[{"distance":{"text":"27 m","value":27},"duration":{"text":"1 min","value":6},"end_location":{"lat":19.185599,"lng":72.9558468},"html_instructions":"Head <b>northeast<\/b> on <b>MP Chowk<\/b> toward <b>SG Barve Rd<\/b>","polyline":{"points":"{dbtBsch|L?AA?AA?AA??AAAAA?A?A?AAA?A?A?A?A?A?A@A?A@A?A@A?A@A"},"start_location":{"lat":19.1855772,"lng":72.9556247},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":870},"duration":{"text":"3 mins","value":165},"end_location":{"lat":19.1883648,"lng":72.963413},"html_instructions":"Exit the roundabout onto <b>Lal Bahadur Shastri Marg<\/b><div style=\"font-size:0.9em\">Pass by Wagle Estate Post Office (on the left)<\/div>","polyline":{"points":"_ebtBaeh|LWoAOcAEe@A_AA{AMcBEQC]COOqAk@sDcAaE_@_Ac@}@[o@o@aAk@w@k@w@e@{@s@{AWm@"},"start_location":{"lat":19.185599,"lng":72.9558468},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2448},"duration":{"text":"5 mins","value":316},"end_location":{"lat":19.16823,"lng":72.96618509999999},"html_instructions":"Turn <b>right<\/b> to merge onto <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","polyline":{"points":"gvbtBiti|LQYIOCEGKXEZGp@QvM}CnAWLCNCL?X?jFsAp@QlGaBt@Qh@Of@Mz@WXIRI`@MNGRKrB_AxCqAbCaAz@]^Mb@Mr@Ob@IbDg@v@O|B]XEvAW~@OLAPCN?Z?r@@tG^r@Df@F`@HzDt@lAZl@RrAr@bAn@vC`BtD~B"},"start_location":{"lat":19.1883648,"lng":72.963413},"travel_mode":"DRIVING"},{"distance":{"text":"5.6 km","value":5599},"duration":{"text":"5 mins","value":320},"end_location":{"lat":19.1249579,"lng":72.9390226},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","maneuver":"keep-right","polyline":{"points":"mx~sBuej|LnEnCnElCXNXNtFhDtFhDnc@jW|AbAtL|GZPTN@@@?B@DD@?DB`@X@?rN|I|BtAb@T~X~NzNtHd_@vRhHtDNJh@ZrCzAh@XxAt@lAn@zo@l\\p@ZdCjA~Bz@fGjB"},"start_location":{"lat":19.16823,"lng":72.96618509999999},"travel_mode":"DRIVING"},{"distance":{"text":"1.5 km","value":1518},"duration":{"text":"2 mins","value":95},"end_location":{"lat":19.1122651,"lng":72.93371189999999},"html_instructions":"Keep <b>left<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-left","polyline":{"points":"_jvsB{{d|LtCt@v@VxAj@jKjDj@Pt`@zLrKfD~HhC"},"start_location":{"lat":19.1249579,"lng":72.9390226},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2371},"duration":{"text":"2 mins","value":139},"end_location":{"lat":19.0923682,"lng":72.9255933},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-right","polyline":{"points":"uzssBuzc|LrQlFd@Nd@N|XrInBn@zBp@vQpF`F|AjVpH~PfFzAh@"},"start_location":{"lat":19.1122651,"lng":72.93371189999999},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":921},"duration":{"text":"1 min","value":54},"end_location":{"lat":19.0849757,"lng":72.9217895},"html_instructions":"Continue straight to stay on <b>NH 3<\/b>","maneuver":"straight","polyline":{"points":"i~osB}gb|LZJ|NlEXHTHn@R|@VvAb@tC~@b@NTHh@TB?TJNHZNTL`@T`@Vr@f@d@^`E~C"},"start_location":{"lat":19.0923682,"lng":72.9255933},"travel_mode":"DRIVING"},{"distance":{"text":"0.1 km","value":132},"duration":{"text":"1 min","value":18},"end_location":{"lat":19.0842303,"lng":72.92085449999999},"html_instructions":"Take the exit on the <b>right<\/b> toward <b>Link Rd<\/b>","maneuver":"ramp-right","polyline":{"points":"cpnsBepa|LBV@@@@rBlBDDBDDF@FFT"},"start_location":{"lat":19.0849757,"lng":72.9217895},"travel_mode":"DRIVING"},{"distance":{"text":"0.3 km","value":275},"duration":{"text":"1 min","value":47},"end_location":{"lat":19.0862782,"lng":72.9194201},"html_i
01-05 17:01:09.107 3736-3820/in.test D/xxx: routes: {"bounds":{"northeast":{"lat":19.1885561,"lng":72.9686183},"southwest":{"lat":19.0842303,"lng":72.9075409}},"copyrights":"Map data ©2016 Google","legs":[{"distance":{"text":"15.8 km","value":15818},"duration":{"text":"26 mins","value":1562},"end_address":"Ghatkopar West, Mumbai, Maharashtra, India","end_location":{"lat":19.0908134,"lng":72.9076817},"start_address":"MP Chowk, Thane West, Thane, Maharashtra 400080, India","start_location":{"lat":19.1855772,"lng":72.9556247},"steps":[{"distance":{"text":"27 m","value":27},"duration":{"text":"1 min","value":6},"end_location":{"lat":19.185599,"lng":72.9558468},"html_instructions":"Head <b>northeast<\/b> on <b>MP Chowk<\/b> toward <b>SG Barve Rd<\/b>","polyline":{"points":"{dbtBsch|L?AA?AA?AA??AAAAA?A?A?AAA?A?A?A?A?A?A@A?A@A?A@A?A@A"},"start_location":{"lat":19.1855772,"lng":72.9556247},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":870},"duration":{"text":"3 mins","value":165},"end_location":{"lat":19.1883648,"lng":72.963413},"html_instructions":"Exit the roundabout onto <b>Lal Bahadur Shastri Marg<\/b><div style=\"font-size:0.9em\">Pass by Wagle Estate Post Office (on the left)<\/div>","polyline":{"points":"_ebtBaeh|LWoAOcAEe@A_AA{AMcBEQC]COOqAk@sDcAaE_@_Ac@}@[o@o@aAk@w@k@w@e@{@s@{AWm@"},"start_location":{"lat":19.185599,"lng":72.9558468},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2448},"duration":{"text":"5 mins","value":316},"end_location":{"lat":19.16823,"lng":72.96618509999999},"html_instructions":"Turn <b>right<\/b> to merge onto <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","polyline":{"points":"gvbtBiti|LQYIOCEGKXEZGp@QvM}CnAWLCNCL?X?jFsAp@QlGaBt@Qh@Of@Mz@WXIRI`@MNGRKrB_AxCqAbCaAz@]^Mb@Mr@Ob@IbDg@v@O|B]XEvAW~@OLAPCN?Z?r@@tG^r@Df@F`@HzDt@lAZl@RrAr@bAn@vC`BtD~B"},"start_location":{"lat":19.1883648,"lng":72.963413},"travel_mode":"DRIVING"},{"distance":{"text":"5.6 km","value":5599},"duration":{"text":"5 mins","value":320},"end_location":{"lat":19.1249579,"lng":72.9390226},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","maneuver":"keep-right","polyline":{"points":"mx~sBuej|LnEnCnElCXNXNtFhDtFhDnc@jW|AbAtL|GZPTN@@@?B@DD@?DB`@X@?rN|I|BtAb@T~X~NzNtHd_@vRhHtDNJh@ZrCzAh@XxAt@lAn@zo@l\\p@ZdCjA~Bz@fGjB"},"start_location":{"lat":19.16823,"lng":72.96618509999999},"travel_mode":"DRIVING"},{"distance":{"text":"1.5 km","value":1518},"duration":{"text":"2 mins","value":95},"end_location":{"lat":19.1122651,"lng":72.93371189999999},"html_instructions":"Keep <b>left<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-left","polyline":{"points":"_jvsB{{d|LtCt@v@VxAj@jKjDj@Pt`@zLrKfD~HhC"},"start_location":{"lat":19.1249579,"lng":72.9390226},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2371},"duration":{"text":"2 mins","value":139},"end_location":{"lat":19.0923682,"lng":72.9255933},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-right","polyline":{"points":"uzssBuzc|LrQlFd@Nd@N|XrInBn@zBp@vQpF`F|AjVpH~PfFzAh@"},"start_location":{"lat":19.1122651,"lng":72.93371189999999},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":921},"duration":{"text":"1 min","value":54},"end_location":{"lat":19.0849757,"lng":72.9217895},"html_instructions":"Continue straight to stay on <b>NH 3<\/b>","maneuver":"straight","polyline":{"points":"i~osB}gb|LZJ|NlEXHTHn@R|@VvAb@tC~@b@NTHh@TB?TJNHZNTL`@T`@Vr@f@d@^`E~C"},"start_location":{"lat":19.0923682,"lng":72.9255933},"travel_mode":"DRIVING"},{"distance":{"text":"0.1 km","value":132},"duration":{"text":"1 min","value":18},"end_location":{"lat":19.0842303,"lng":72.92085449999999},"html_instructions":"Take the exit on the <b>right<\/b> toward <b>Link Rd<\/b>","maneuver":"ramp-right","polyline":{"points":"cpnsBepa|LBV@@@@rBlBDDBDDF@FFT"},"start_location":{"lat":19.0849757,"lng":72.9217895},"travel_mode":"DRIVING"},{"distance":{"text":"0.3 km","value":275},"duration":{"text":"1 min","value":47},"end_location":{"lat":19.0862782,"lng":72.9194201},"html_i
01-05 17:01:09.107 3736-3820/in.test D/xxx: legs: [{"distance":{"text":"15.8 km","value":15818},"duration":{"text":"26 mins","value":1562},"end_address":"Ghatkopar West, Mumbai, Maharashtra, India","end_location":{"lat":19.0908134,"lng":72.9076817},"start_address":"MP Chowk, Thane West, Thane, Maharashtra 400080, India","start_location":{"lat":19.1855772,"lng":72.9556247},"steps":[{"distance":{"text":"27 m","value":27},"duration":{"text":"1 min","value":6},"end_location":{"lat":19.185599,"lng":72.9558468},"html_instructions":"Head <b>northeast<\/b> on <b>MP Chowk<\/b> toward <b>SG Barve Rd<\/b>","polyline":{"points":"{dbtBsch|L?AA?AA?AA??AAAAA?A?A?AAA?A?A?A?A?A?A@A?A@A?A@A?A@A"},"start_location":{"lat":19.1855772,"lng":72.9556247},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":870},"duration":{"text":"3 mins","value":165},"end_location":{"lat":19.1883648,"lng":72.963413},"html_instructions":"Exit the roundabout onto <b>Lal Bahadur Shastri Marg<\/b><div style=\"font-size:0.9em\">Pass by Wagle Estate Post Office (on the left)<\/div>","polyline":{"points":"_ebtBaeh|LWoAOcAEe@A_AA{AMcBEQC]COOqAk@sDcAaE_@_Ac@}@[o@o@aAk@w@k@w@e@{@s@{AWm@"},"start_location":{"lat":19.185599,"lng":72.9558468},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2448},"duration":{"text":"5 mins","value":316},"end_location":{"lat":19.16823,"lng":72.96618509999999},"html_instructions":"Turn <b>right<\/b> to merge onto <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","polyline":{"points":"gvbtBiti|LQYIOCEGKXEZGp@QvM}CnAWLCNCL?X?jFsAp@QlGaBt@Qh@Of@Mz@WXIRI`@MNGRKrB_AxCqAbCaAz@]^Mb@Mr@Ob@IbDg@v@O|B]XEvAW~@OLAPCN?Z?r@@tG^r@Df@F`@HzDt@lAZl@RrAr@bAn@vC`BtD~B"},"start_location":{"lat":19.1883648,"lng":72.963413},"travel_mode":"DRIVING"},{"distance":{"text":"5.6 km","value":5599},"duration":{"text":"5 mins","value":320},"end_location":{"lat":19.1249579,"lng":72.9390226},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","maneuver":"keep-right","polyline":{"points":"mx~sBuej|LnEnCnElCXNXNtFhDtFhDnc@jW|AbAtL|GZPTN@@@?B@DD@?DB`@X@?rN|I|BtAb@T~X~NzNtHd_@vRhHtDNJh@ZrCzAh@XxAt@lAn@zo@l\\p@ZdCjA~Bz@fGjB"},"start_location":{"lat":19.16823,"lng":72.96618509999999},"travel_mode":"DRIVING"},{"distance":{"text":"1.5 km","value":1518},"duration":{"text":"2 mins","value":95},"end_location":{"lat":19.1122651,"lng":72.93371189999999},"html_instructions":"Keep <b>left<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-left","polyline":{"points":"_jvsB{{d|LtCt@v@VxAj@jKjDj@Pt`@zLrKfD~HhC"},"start_location":{"lat":19.1249579,"lng":72.9390226},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2371},"duration":{"text":"2 mins","value":139},"end_location":{"lat":19.0923682,"lng":72.9255933},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-right","polyline":{"points":"uzssBuzc|LrQlFd@Nd@N|XrInBn@zBp@vQpF`F|AjVpH~PfFzAh@"},"start_location":{"lat":19.1122651,"lng":72.93371189999999},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":921},"duration":{"text":"1 min","value":54},"end_location":{"lat":19.0849757,"lng":72.9217895},"html_instructions":"Continue straight to stay on <b>NH 3<\/b>","maneuver":"straight","polyline":{"points":"i~osB}gb|LZJ|NlEXHTHn@R|@VvAb@tC~@b@NTHh@TB?TJNHZNTL`@T`@Vr@f@d@^`E~C"},"start_location":{"lat":19.0923682,"lng":72.9255933},"travel_mode":"DRIVING"},{"distance":{"text":"0.1 km","value":132},"duration":{"text":"1 min","value":18},"end_location":{"lat":19.0842303,"lng":72.92085449999999},"html_instructions":"Take the exit on the <b>right<\/b> toward <b>Link Rd<\/b>","maneuver":"ramp-right","polyline":{"points":"cpnsBepa|LBV@@@@rBlBDDBDDF@FFT"},"start_location":{"lat":19.0849757,"lng":72.9217895},"travel_mode":"DRIVING"},{"distance":{"text":"0.3 km","value":275},"duration":{"text":"1 min","value":47},"end_location":{"lat":19.0862782,"lng":72.9194201},"html_instructions":"Continue onto <b>Link Rd<\/b><div style=\"font-size:0.9em\">Pass by A 3 (on the left)<\/div>","polyline":{"points":"mknsBija|LIRoDtB{BpAcB`A"
01-05 17:01:09.117 3736-3820/in.test D/JSON: steps: {"distance":{"text":"15.8 km","value":15818},"duration":{"text":"26 mins","value":1562},"end_address":"Ghatkopar West, Mumbai, Maharashtra, India","end_location":{"lat":19.0908134,"lng":72.9076817},"start_address":"MP Chowk, Thane West, Thane, Maharashtra 400080, India","start_location":{"lat":19.1855772,"lng":72.9556247},"steps":[{"distance":{"text":"27 m","value":27},"duration":{"text":"1 min","value":6},"end_location":{"lat":19.185599,"lng":72.9558468},"html_instructions":"Head <b>northeast<\/b> on <b>MP Chowk<\/b> toward <b>SG Barve Rd<\/b>","polyline":{"points":"{dbtBsch|L?AA?AA?AA??AAAAA?A?A?AAA?A?A?A?A?A?A@A?A@A?A@A?A@A"},"start_location":{"lat":19.1855772,"lng":72.9556247},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":870},"duration":{"text":"3 mins","value":165},"end_location":{"lat":19.1883648,"lng":72.963413},"html_instructions":"Exit the roundabout onto <b>Lal Bahadur Shastri Marg<\/b><div style=\"font-size:0.9em\">Pass by Wagle Estate Post Office (on the left)<\/div>","polyline":{"points":"_ebtBaeh|LWoAOcAEe@A_AA{AMcBEQC]COOqAk@sDcAaE_@_Ac@}@[o@o@aAk@w@k@w@e@{@s@{AWm@"},"start_location":{"lat":19.185599,"lng":72.9558468},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2448},"duration":{"text":"5 mins","value":316},"end_location":{"lat":19.16823,"lng":72.96618509999999},"html_instructions":"Turn <b>right<\/b> to merge onto <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","polyline":{"points":"gvbtBiti|LQYIOCEGKXEZGp@QvM}CnAWLCNCL?X?jFsAp@QlGaBt@Qh@Of@Mz@WXIRI`@MNGRKrB_AxCqAbCaAz@]^Mb@Mr@Ob@IbDg@v@O|B]XEvAW~@OLAPCN?Z?r@@tG^r@Df@F`@HzDt@lAZl@RrAr@bAn@vC`BtD~B"},"start_location":{"lat":19.1883648,"lng":72.963413},"travel_mode":"DRIVING"},{"distance":{"text":"5.6 km","value":5599},"duration":{"text":"5 mins","value":320},"end_location":{"lat":19.1249579,"lng":72.9390226},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b><div style=\"font-size:0.9em\">Partial toll road<\/div>","maneuver":"keep-right","polyline":{"points":"mx~sBuej|LnEnCnElCXNXNtFhDtFhDnc@jW|AbAtL|GZPTN@@@?B@DD@?DB`@X@?rN|I|BtAb@T~X~NzNtHd_@vRhHtDNJh@ZrCzAh@XxAt@lAn@zo@l\\p@ZdCjA~Bz@fGjB"},"start_location":{"lat":19.16823,"lng":72.96618509999999},"travel_mode":"DRIVING"},{"distance":{"text":"1.5 km","value":1518},"duration":{"text":"2 mins","value":95},"end_location":{"lat":19.1122651,"lng":72.93371189999999},"html_instructions":"Keep <b>left<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-left","polyline":{"points":"_jvsB{{d|LtCt@v@VxAj@jKjDj@Pt`@zLrKfD~HhC"},"start_location":{"lat":19.1249579,"lng":72.9390226},"travel_mode":"DRIVING"},{"distance":{"text":"2.4 km","value":2371},"duration":{"text":"2 mins","value":139},"end_location":{"lat":19.0923682,"lng":72.9255933},"html_instructions":"Keep <b>right<\/b> to stay on <b>NH 3<\/b>","maneuver":"keep-right","polyline":{"points":"uzssBuzc|LrQlFd@Nd@N|XrInBn@zBp@vQpF`F|AjVpH~PfFzAh@"},"start_location":{"lat":19.1122651,"lng":72.93371189999999},"travel_mode":"DRIVING"},{"distance":{"text":"0.9 km","value":921},"duration":{"text":"1 min","value":54},"end_location":{"lat":19.0849757,"lng":72.9217895},"html_instructions":"Continue straight to stay on <b>NH 3<\/b>","maneuver":"straight","polyline":{"points":"i~osB}gb|LZJ|NlEXHTHn@R|@VvAb@tC~@b@NTHh@TB?TJNHZNTL`@T`@Vr@f@d@^`E~C"},"start_location":{"lat":19.0923682,"lng":72.9255933},"travel_mode":"DRIVING"},{"distance":{"text":"0.1 km","value":132},"duration":{"text":"1 min","value":18},"end_location":{"lat":19.0842303,"lng":72.92085449999999},"html_instructions":"Take the exit on the <b>right<\/b> toward <b>Link Rd<\/b>","maneuver":"ramp-right","polyline":{"points":"cpnsBepa|LBV@@@@rBlBDDBDDF@FFT"},"start_location":{"lat":19.0849757,"lng":72.9217895},"travel_mode":"DRIVING"},{"distance":{"text":"0.3 km","value":275},"duration":{"text":"1 min","value":47},"end_location":{"lat":19.0862782,"lng":72.9194201},"html_instructions":"Continue onto <b>Link Rd<\/b><div style=\"font-size:0.9em\">Pass by A 3 (on the left)<\/div>","polyline":{"points":"mknsBija|LIRoDtB{BpAcB`A
01-05 17:01:09.117 3736-3820/in.test D/xxx: distance: {"text":"15.8 km","value":15818}
01-05 17:01:09.117 3736-3820/in.test D/SEE THE DIST :: 15.8 km15818

СПАСИБО КЕННИ!

0 голосов
/ 14 апреля 2013

Я видел, что несколько человек ответили правильно, но посмотрите на этот ответ.Очень полезный API для использования API карты Google. Использование API Google Maps Direction

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...