Anil
Anil

Reputation: 253

Voice route navigation google map android

Am trying to implement Voice route navigation Google map for my project. But i don't have any idea how to implement this. I have starting and ending points.Can i implement in my application or redirect to phones default Google map ? Please guide me ..

Upvotes: 0

Views: 1360

Answers (1)

AndHobbiest
AndHobbiest

Reputation: 131

Process the following URL to get Locations between the source and destination coordinates

StringBuilder urlString = new StringBuilder();
            urlString.append("http://maps.google.com/maps/api/directions/xml?origin=");
            urlString.append( Double.toString((double)srcGeoPoint.getLatitudeE6()/1.0E6 )); 
            urlString.append(","); 
            urlString.append( Double.toString((double)srcGeoPoint.getLongitudeE6()/1.0E6 )); 
            urlString.append("&destination=");//to 
            urlString.append( Double.toString((double)destGeoPoint.getLatitudeE6()/1.0E6 )); 
            urlString.append(","); 
            urlString.append( Double.toString((double)destGeoPoint.getLongitudeE6()/1.0E6 )); 
            urlString.append("&sensor=true&mode=driving"); 

After getting response from above URL Encode the string with following method

private List<GeoPoint> decodePoly(String encoded) {

            List<GeoPoint> poly = new ArrayList<GeoPoint>();
            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;

                GeoPoint p = new GeoPoint((int) (((double) lat / 1E5) * 1E6),
                        (int) (((double) lng / 1E5) * 1E6));
                poly.add(p);
            }

            return poly;
        }

after encode the between locations you draw path using canvas drawing .

NOTE: FOR Voice Route you may use TTS(Text To Speech)

Upvotes: 1

Related Questions