提取地图中已铺设路线的时间



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

这是带有映射的代码片段。

        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);
            }
        });

您需要使用谷歌地图Api(Web),我认为安卓地图Api不会返回路线持续时间。

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

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

最新更新