Search code examples
javaandroidgoogle-maps-api-2

Draw five transparent circles on the google map v2 by taking current location as the center of circle


I need to draw five circle-circle on the Google Maps v2 by taking the current location as the center of a circle. Meaning that each of the five circles have the same center but with different radii: the first circle will have radius of 10m, second circle radius of 20m, third circle radius of 30m, fourth circle radius of 40m, and fifth circle radius of 50m. I am using Google Maps v2.

And I need to show a marker on the center of the circle as well.

I am trying something like this to draw the circle on the Google Map v2 but it draws only one circle and not the five circum-circle

CircleOptions circleOptions = new CircleOptions()
                  .center(latLng)   //set center
                  .radius(500)   //set radius in meters
                  .fillColor(Color.TRANSPARENT)  //default
                  .strokeColor(0x10000000)
                  .strokeWidth(5);

                  myCircle = googleMap.addCircle(circleOptions);

I need to draw circum-circle exactly like this-

enter image description here

Can anybody help me with this? I am having problem in making this circle in Google Map v2. Any help will be appreciated.


Solution

  • for(int rad=100;rad<=500;rad+100)
    {
    
        CircleOptions circleOptions = new CircleOptions()
                  .center(latLng)   //set center
                  .radius(rad)   //set radius in meters
                  .fillColor(Color.TRANSPARENT)  //default
                  .strokeColor(0x10000000)
                  .strokeWidth(5);
    
                  myCircle = googleMap.addCircle(circleOptions);
    }