3

I create the Google Map using android i get my current location latitude longitude values and using some other latitude longitude value.Now how to draw the shortest path line in 2 location. My Main Activity.java:

public class MainActivity extends Activity {
GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
            .getMap();
    map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    LatLng latLng = new LatLng(13.0847992, 80.2125527);
    map.addMarker(new MarkerOptions().position(latLng).title("Anna Nagar"));

    map.setMyLocationEnabled(true);
    map.getUiSettings().setZoomControlsEnabled(true);
    map.getUiSettings().setCompassEnabled(true);
    map.getUiSettings().setMyLocationButtonEnabled(true);
    map.getUiSettings().setAllGesturesEnabled(true);
    map.setTrafficEnabled(true);

}
}
Jai
  • 486
  • 1
  • 8
  • 21
  • use this link help full for you http://stackoverflow.com/questions/14702621/answer-draw-path-between-two-points-using-google-maps-android-api-v2 – Mr. Jan 22 '15 at 05:31
  • ya k................... – Jai Jan 22 '15 at 05:46

1 Answers1

1

Draw a path between your location to another location used MapNavigator library. It easy to used.

eg.

LatLng startLocation = new LatLng(start_lat, start_long);
LatLng endLocation = new LatLng(end_lat, end_long);

map.addMarker(new MarkerOptions().position(startLocation ).title("start"));
map.addMarker(new MarkerOptions().position(endLocation ).title("end"));

Navigator navigator = new Navigator(map, startLocation, endLocation);
navigator.findDirections(true);
Jigar Shekh
  • 2,800
  • 6
  • 29
  • 54