Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw transparent circles on Google Maps API

I try to draw circles on the Google Maps API, which are transparent.

CircleOptions circleOptions = new CircleOptions()
        .center(new LatLng(lat, lon))
        .radius(50.0)
        .strokeColor(Color.TRANSPARENT)
        .strokeWidth(1)
        .fillColor(Color.CYAN); // 

But I like to draw them transparently, so that I can see the map behind? How could I do that?

like image 463
Ralf Wickum Avatar asked Dec 05 '22 00:12

Ralf Wickum


2 Answers

For mGoogleMap as GoogleMap object, with latitude longitude given as

LatLng currentLatLon = new LatLng(lat double value, lng double value);

This is the way to draw circle in google maps

mGoogleMap.addCircle(new CircleOptions()
                    .center(currentLatLon)
                    .radius(150)
                    .strokeColor(Color.RED)
                    .fillColor(0x220000FF)
                    .strokeWidth(5)
                    );
like image 98
Sreehari Avatar answered Jan 30 '23 16:01

Sreehari


This will add the transparent circle around the marker

Circle mCircle = mMap.addCircle(new CircleOptions()
                 .center(new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()))
                 .radius(500)
                 .strokeWidth(0)
                 .strokeColor(Color.parseColor("#2271cce7"))
                 .fillColor(Color.parseColor("#2271cce7")));

For the Transparent Color you can set it to any Color using i.e #2271cce7

In the above the actual color code is #71cce7 and the first two digits of 22 indicate the transparency which can be set to any value to either increase or decrease transparency.

View Sample

like image 37
Sugoi Reed Avatar answered Jan 30 '23 15:01

Sugoi Reed