相关疑难解决方法(0)

android从maps.google.com指示获取持续时间

目前我正在使用此代码查询谷歌地图以查找从地址到另一个地址的路线,然后我只是从其GeometryCollection的mapview上绘制它.但是这还不够,我还需要从kml中提取总预期持续时间.有人可以提供一些示例代码来帮助我吗?谢谢

StringBuilder urlString = new StringBuilder();
urlString.append("http://maps.google.com/maps?f=d&hl=en");
urlString.append("&saddr=");//from
urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 ));
urlString.append("&daddr=");//to
urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 ));
urlString.append("&ie=UTF8&0&om=0&output=kml");
//Log.d("xxx","URL="+urlString.toString());
// get the kml (XML) doc. And parse it to get the coordinates(direction route).
Document doc = null;
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();
    dbf = DocumentBuilderFactory.newInstance();
    db = dbf.newDocumentBuilder();
    doc = db.parse(urlConnection.getInputStream());
    if(doc.getElementsByTagName("GeometryCollection").getLength()>0)
    {
        //String path = doc.getElementsByTagName("GeometryCollection").item(0).getFirstChild().getFirstChild().getNodeName();
        String path = doc.getElementsByTagName("GeometryCollection").item(0).getFirstChild().getFirstChild().getFirstChild().getNodeValue() …
Run Code Online (Sandbox Code Playgroud)

java android google-maps duration map-directions

0
推荐指数
1
解决办法
7906
查看次数

标签 统计

android ×1

duration ×1

google-maps ×1

java ×1

map-directions ×1