Passing longitude and latitude to google directions api

Jonathan Ogle-Barrington picture Jonathan Ogle-Barrington · Jan 12, 2012 · Viewed 9.8k times · Source

I am having issues with passing a longitude and latitude to the google directions api (http://code.google.com/apis/maps/documentation/directions/) can anyone tell me what i am doing wrong, i am always getting no results but if i use address its fine

JSONObject jsonLocation = JSONfunctions.getJSONfromURL("http://maps.googleapis.com/maps/api/directions/json?origin=" + currentLongitude + "," +  currentLatitude + "&destination=" + longitude + "," + longitude +"&sensor=true&region=gb");

Thanks

Answer

bindal picture bindal · Jan 12, 2012

Use this Code

Intent intent = new Intent(
                            android.content.Intent.ACTION_VIEW,
                            Uri.parse("http://maps.google.com/maps?saddr="+ latitude + "," + Longitude+ "&daddr="+latitudeDb+","+longitudeDb+""));
                    intent.setClassName("com.google.android.apps.maps",
                            "com.google.android.maps.MapsActivity");
                    startActivity(intent);