Search code examples
androidjsongpsandroid-maps-v2driving-directions

Is JSON direction parser the only way to draw directions between two GPS co-ordinates?


I'm building an app which has to get the present GPS location of the phone and depending upon the difference between the present location and 5 other locations, the app has to provide the smallest possible route from present to nearest location.

I'm a rookie in this area of programming. So all i found out was to use the JSON parser code. I removed all of the errors by going through all the Q&A's in this site and many others, but all I got was a world map.

I even found out a single class that could do it, but still it didn't work out. So all i am asking is that, Is there a simple class that could do that (i.e, provide directions between 2 static GPS locations) ??

If anyone needs i will put forth the classes(You would know the DirectionJSONparser class if you are responding to this Que).


Solution

  • Found it .

    button = (Button) this.findViewById(R.id.button1);
            button.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", destinationLatitude, destinationLongitude, "Nearest Hospital");
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                    startActivity(intent);
    
                }
            });