Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a Circle GeoFence with Preview in Android

First of all my question is a bit different from other questions about GeoFencing in gmap in Android.

When the user start to define a circle as a GeoFence area I want to show a fixed circle in the center of the screen. In this stage the user should be able to move the map and map's zoom level. Neither move action nor zoom in/out action can change the size of the circle relative to the screen.

When the user press to save button I want to pin that circle to the map as a CircleOption object. Then I will be able to get lon/lat and radius of CircleOption object in meters.

I am currently working on RelativeLayout issue. I draw a fixed circle with RelativeLayout as I expect however I couldn't get current radius of that RelativeLayout circle. You can see how my RelativeLayout looks like right now:

enter image description here

I am not sure about the correct way of doing this. My searches redirected me to use RelativeLayout and then CircleOption. What is your advice?

Thanks in advance!

like image 730
Harun Oğuzorhan Avatar asked Feb 11 '23 08:02

Harun Oğuzorhan


1 Answers

https://developers.google.com/android/reference/com/google/android/gms/maps/model/Circle


CircleOptions circleOptions = new CircleOptions()
  .center( new LatLng(fence.getLatitude(), fence.getLongitude()) )
  .radius( fence.getRadius() )
  .fillColor(0x40ff0000) <Your Color code>
  .strokeColor(Color.TRANSPARENT)
  .strokeWidth(2);
like image 152
Jignesh Goyani Avatar answered Feb 23 '23 13:02

Jignesh Goyani