Xamarin Android: Create Google Map Draw Circle Around Marker

In this article you will create a new Xamarin Android Google Map Draw Circle around Marker.

Let’s start,

We already created a Google Map with Marker in my article. If you did not create this please follow this link,

After creating Google Map with Marker App in Xamarin Android, then follow the below steps,

Step 1: Open MainActivity.cs page, then give following code,

 

Name Space: 

  1. using Android.Gms.Maps.Model; // Add this Two Name Space  
  2.   
  3.                            using Android.Graphics;  

C# Code:

  1. public void OnMapReady(GoogleMap googleMap)  
  2.   
  3. {  
  4.   
  5. this.GMap = googleMap;  
  6.   
  7. GMap.UiSettings.ZoomControlsEnabled = true;  
  8.   
  9. DrawCircle(GMap); //Calling Draw Circle  
  10.   
  11. LatLng latlng = new LatLng(Convert.ToDouble(13.0291), Convert.ToDouble(80.2083));  
  12.   
  13. CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);  
  14.   
  15. GMap.MoveCamera(camera);  
  16.   
  17. MarkerOptions options = new MarkerOptions()  
  18.   
  19. .SetPosition(latlng)  
  20.   
  21. .SetTitle("Chennai");  
  22.   
  23. GMap.AddMarker(options);  
  24.   
  25. }  
  26.   
  27. public void DrawCircle(GoogleMap gMap)  
  28.   
  29. {  
  30.   
  31. Circle circle;  
  32.   
  33. var CircleMaker = new CircleOptions();  
  34.   
  35. var latlong = new LatLng(13.0291, 80.2083); //Location  
  36.   
  37. CircleMaker.InvokeCenter(latlong); //  
  38.   
  39. CircleMaker.InvokeRadius(1000); //Radius in Circle  
  40.   
  41. CircleMaker.InvokeStrokeWidth(4);  
  42.   
  43. CircleMaker.InvokeStrokeColor(Android.Graphics.Color.ParseColor("#e6d9534f")); //Circle Color  
  44.   
  45. CircleMaker.InvokeFillColor(Color.Argb(034, 209, 72, 54));  
  46.   
  47. CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlong, 15); //Map Zoom Level  
  48.   
  49. circle = GMap.AddCircle(CircleMaker); //Gmap Add Circle  
  50.   
  51.   
  52.   
  53. }  

Step 2: Next Run the app showing Drawing Circle in Around Marker with Google Map,

 

Finally, we have successfully created Xamarin Android Google Map Draw Circle around Marker App.

Read more articles on Xamarin: