0

I have a page(fragment) that shows google maps together with 1 marker icon. So now i would like to pass source and destination coordinates to this map so that it can show the shortest route together with the distance in Km. E.g i want the map to show the blue path in the image below :

enter image description here

Here is my code :

private void SetUpMap()
 {
       if (GMap == null)
       {
           ChildFragmentManager.FindFragmentById<MapFragment>(Resource.Id.googlemap).GetMapAsync(this);
        }
 }

public void OnMapReady(GoogleMap googleMap)
{

                this.GMap = googleMap;
                GMap.UiSettings.ZoomControlsEnabled = true;

                LatLng latlng = new LatLng(Convert.ToDouble(gpsLatitude), Convert.ToDouble(gpsLongitude));
                CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);
                GMap.MoveCamera(camera);

                MarkerOptions options = new MarkerOptions()
                           .SetPosition(latlng)
                           .SetTitle("Chennai");

                GMap.AddMarker(options);
}
code11
  • 1,986
  • 5
  • 29
  • 37
chosenOne Thabs
  • 1,480
  • 3
  • 21
  • 39
  • https://developer.xamarin.com/guides/android/platform_features/maps_and_location/maps/part_2_-_maps_api/ – Jason Nov 15 '16 at 21:21
  • Ref: http://stackoverflow.com/questions/37189634/api-google-maps-doesnt-return-enough-of-step/37191234#37191234 – SushiHangover Nov 16 '16 at 00:01

1 Answers1

0

I got my answer from this post :

Adding polyline between two locations google maps api v2

I converted the java code to C# and it worked fine.

Community
  • 1
  • 1
chosenOne Thabs
  • 1,480
  • 3
  • 21
  • 39