0

我在我的应用程序中使用地图。我正在输入位置,地图打开。例如,我在那里找到了方向。地图计算到达输入点所需的时间。我可以以编程方式获得这段时间在我的应用程序中使用吗?

这是带有地图的代码片段。

        Button destination_button = (Button) findViewById(R.id.button1);
        destination_button.getBackground().setAlpha(64);

        final EditText destination_tw = (EditText) findViewById(R.id.editText1);

        destination_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String string_for_entering_destination;

                string_for_entering_destination = "q=" + destination_tw.getText().toString() + "&z=8";
                // TODO Auto-generated method stub
//              String geoUriString = "geo:0,10?z=2";
                String geoUriString = "geo:0,0?" + string_for_entering_destination;
                Uri geoUri = Uri.parse(geoUriString);
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, geoUri);
                startActivity(mapIntent);
            }
        });
4

1 回答 1

0

您将需要使用 Google Maps Api (Web) 我认为 Android Maps Api 不会返回路线持续时间。

使用此参考来实现:https ://developers.google.com/maps/documentation/directions

您将使用请求的参数(如 startPoint 和 EndPoint)发出 Http 请求,API 将向您发送回 JSON 响应,其中包含持续时间等一系列信息。

于 2015-12-19T18:47:58.620 回答