0

I am trying to add Google Maps to my Android App and have several location pointers. My question is how can I show direction and get the distance between my location to a specific lat-lon position.

Here is my XML Fragment

   <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ContactDetail" />

Here is my activity code to show the Map

public class ContactDetail extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.view_contact_hd);

        //-----------Google Maps-------------------
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);

        //-----------------------------------------------

    } //ENd of savedInstanceState

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        LatLng pp = new LatLng(23.72553, 90.41577);
        mMap.getUiSettings().setZoomControlsEnabled(true);
        mMap.addMarker(new MarkerOptions().position(pp).title("Sreebordi Branch"));
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pp, 14));
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Firefog
  • 3,094
  • 7
  • 48
  • 86

0 Answers0