Java 如何在google map v2中获取所有路由节点的音频轨迹

Java 如何在google map v2中获取所有路由节点的音频轨迹,java,android,json,google-maps,navigation,Java,Android,Json,Google Maps,Navigation,在我的项目中,我需要制作一个导航应用程序,为盲人用户提供方向,因此我需要获取谷歌地图中所有路由节点的音频轨迹。我在网上参考了很多导航教程,但是我没有得到我需要的。对于任何帮助,我都感谢你 这是我的jsonparser类 public class DirectionsJSONParser { /** Receives a JSONObject and returns a list of lists containing latitude and longitude */ public List&

在我的项目中,我需要制作一个导航应用程序,为盲人用户提供方向,因此我需要获取谷歌地图中所有路由节点的音频轨迹。我在网上参考了很多导航教程,但是我没有得到我需要的。对于任何帮助,我都感谢你

这是我的jsonparser类

public class DirectionsJSONParser {

/** Receives a JSONObject and returns a list of lists containing latitude and longitude */
public List<List<HashMap<String,String>>> parse(JSONObject jObject){

    List<List<HashMap<String, String>>> routes = new ArrayList<List<HashMap<String,String>>>() ;
    JSONArray jRoutes = null;
    JSONArray jLegs = null;
    JSONArray jSteps = null;

    try {
        jRoutes = jObject.getJSONArray("routes");

        /** Traversing all routes */
        for(int i=0;i<jRoutes.length();i++){
            jLegs = ( (JSONObject)jRoutes.get(i)).getJSONArray("legs");
            List path = new ArrayList<HashMap<String, String>>();

            /** Traversing all legs */
            for(int j=0;j<jLegs.length();j++){
                jSteps = ( (JSONObject)jLegs.get(j)).getJSONArray("steps");

                /** Traversing all steps */
                for(int k=0;k<jSteps.length();k++){
                    String polyline = "";
                   // polyline = (String)((JSONObject)((JSONObject)jSteps.get(k)).get("polyline")).get("formatted_address");
                    polyline = (String)((JSONObject)((JSONObject)jSteps.get(k)).get("polyline")).get("points");
                    List<LatLng> list = decodePoly(polyline);

                    /** Traversing all points */
                    for(int l=0;l<list.size();l++){
                        HashMap<String, String> hm = new HashMap<String, String>();
                        hm.put("lat", Double.toString(((LatLng)list.get(l)).latitude) );
                        hm.put("lng", Double.toString(((LatLng)list.get(l)).longitude) );
                        path.add(hm);
                    }
                }
            routes.add(path);
        }
    }

} catch (JSONException e) {
    e.printStackTrace();
}catch (Exception e){
}

return routes;
}
/**
* Method to decode polyline points
* Courtesy : http://jeffreysambells.com/2010/05/27/decoding-polylines-from-google-maps-direction-api-with-java
* */
private List<LatLng> decodePoly(String encoded) {

    List<LatLng> poly = new ArrayList<LatLng>();
    int index = 0, len = encoded.length();
    int lat = 0, lng = 0;

    while (index < len) {
        int b, shift = 0, result = 0;
        do {
            b = encoded.charAt(index++) - 63;
            result |= (b & 0x1f) << shift;
            shift += 5;
        } while (b >= 0x20);
        int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
        lat += dlat;

        shift = 0;
        result = 0;
        do {
            b = encoded.charAt(index++) - 63;
            result |= (b & 0x1f) << shift;
            shift += 5;
        } while (b >= 0x20);
        int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
        lng += dlng;

        LatLng p = new LatLng((((double) lat / 1E5)),
            (((double) lng / 1E5)));
        poly.add(p);
    }

    return poly;
}
公共类方向JSONParser{
/**接收JSONObject并返回包含纬度和经度的列表列表*/
公共列表解析(JSONObject jObject){
列表路由=新建ArrayList();
JSONArray jRoutes=null;
JSONArray jLegs=null;
JSONArray jSteps=null;
试一试{
jRoutes=jObject.getJSONArray(“路由”);
/**穿越所有路线*/
对于(int i=0;i 1));
lat+=dlat;
移位=0;
结果=0;
做{
b=编码的.charAt(索引++)-63;
结果|=(b&0x1f)=0x20);
int-dlng=((结果&1)!=0?~(结果>>1):(结果>>1));
液化天然气+=液化天然气;
LatLng p=新LatLng(((双)lat/1E5)),
((双)液化天然气/1E5));
poly.add(p);
}
返回多边形;
}

}

没有关于方向的音频曲目,但是看起来您使用的是
谷歌方向API
,如果您查看,您会看到路线的说明在JSON中以
html\u说明的形式返回给您

然后,您要做的是使用说明,并使用
文本到语音(TTS)
引擎说出它

但是

TOS

Google Maps/Google Earth APIs Terms of Service

Last updated: May 27, 2009
...
10. License Restrictions. Except as expressly permitted under the Terms, or unless you
have received prior written authorization from Google (or, as applicable, from the
provider of particular Content), Google's licenses above are subject to your adherence
to all of the restrictions below. Except as explicitly permitted in Section 7 or the
Maps APIs Documentation, you must not (nor may you permit anyone else to):
...
10.9 use the Service or Content with any products, systems, or applications for or in
connection with:

(a) real time navigation or route guidance, including but not limited to turn-by-turn
route guidance that is synchronized to the position of a user's sensor-enabled device;

and may be disabled for certain apps (somehow, at least on Android)... FromGeocode
scraping in .NET conversation:
This is not allowed by the API terms of use. You should not scrape Google Maps to
generate geocodes. We will block services that do automated queries of our servers.

Bret Taylor
Product Manager, Google Maps