How To Draw A Mileage Circle On Google Maps
I am using the new API(Google Map API V2) for my android application, i have done creating the map and adding markers to it, now my task is to manually create a circumvolve around whatsoever of the marker and besides i want to provide a functionality to the user that he tin increase the radius of that circumvolve appropriately, for this i have given a bar, when user increases that bar the radius of circumvolve will increase and vice versa.
If anybody knows how to practise this using Google Map API V2 so please help,
asked Jul 9, 2022 at 11:18
Sinku PaliwalSinku Paliwal
203 1 gold bluecoat 3 silver badges 8 bronze badges
5 Answers v
endeavor this code
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tag_map); // Drawing circle on the map drawCircle(new LatLng(Latitude, Longitude)); } private void drawCircle(LatLng signal){ // Instantiating CircleOptions to draw a circle around the marker CircleOptions circleOptions = new CircleOptions(); // Specifying the center of the circle circleOptions.center(point); // Radius of the circle circleOptions.radius(20); // Edge color of the circle circleOptions.strokeColor(Color.BLACK); // Fill colour of the circumvolve circleOptions.fillColor(0x30ff0000); // Edge width of the circumvolve circleOptions.strokeWidth(2); // Adding the circumvolve to the GoogleMap googleMap.addCircle(circleOptions); }
answered Jul 9, 2022 at eleven:29
Finava VipulFinava Vipul
978 1 gold badge 11 silver badges 24 statuary badges
3
Add the following code in onMapReady()
method:
Circle circle = map.addCircle(new CircleOptions() .eye(new LatLng(breadth, longitude)) .radius(10000) .strokeColor(Color.RED) .fillColor(Color.Blue));
where map
is the object of GoogleMap
class.
nalzok
13.1k xviii aureate badges 61 silver badges 115 bronze badges
answered Apr 22, 2022 at 17:04
Lalit KushwahLalit Kushwah
3,480 iv aureate badges 23 argent badges 36 bronze badges
Google Maps tin can use semi-transparent color for the circle.
private var circle: Circumvolve? = nothing private fun drawCircle(latitude: Double, longitude: Double, radius: Double) { val circleOptions = CircleOptions() .eye(LatLng(latitude, longitude)) .radius(radius) .strokeWidth(1.0f) .strokeColor(ContextCompat.getColor(context!!, R.color.color1)) .fillColor(ContextCompat.getColor(context!!, R.color.color2)) circumvolve?.remove() // Remove erstwhile circle. circle = googleMap?.addCircle(circleOptions) // Describe new circle. }
answered May 29, 2022 at ten:24
CoolMindCoolMind
21.4k 12 gold badges 162 silverish badges 191 bronze badges
CircleOptions circleOptions = new CircleOptions(); circleOptions.middle(new LatLng(location.getLatitude(),location.getLongitude())); circleOptions.radius(700); circleOptions.fillColor(Color.TRANSPARENT); circleOptions.strokeWidth(vi); mMap.addCircle(circleOptions); geocoder = new Geocoder(MapsActivity.this, getDefault()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(new LatLng(location.getLatitude(), location.getLongitude())); mMap.addMarker(markerOptions.championship(String.valueOf(location)));
endeavor this
answered Jul 7, 2022 at five:57
1
-
While this code snippet may be the solution, including an caption really helps to ameliorate the quality of your mail. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code proposition.
Jul 7, 2022 at 9:24
Kotlin version of @Lalit Kushwah
map.addCircle( CircleOptions() .center([Your LatLng]) .radius(10000.0) .strokeColor(Color.Carmine) .fillColor(Color.BLUE) )
answered Aug 14, 2022 at 23:07
AmosAmos
1,491 1 aureate badge 20 argent badges 33 statuary badges
Non the respond you're looking for? Scan other questions tagged android or ask your own question.
Source: https://stackoverflow.com/questions/31315873/android-how-to-draw-a-circle-on-google-map
Posted by: vaughnreyel1980.blogspot.com
yes it good but my job is to manage the marker circle from the seek bar
Jul 10, 2022 at 6:35
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub pro=progress; googleMap.addCircle(new CircleOptions() .center(new LatLng(point.latitude,betoken.longitude)) .radius(pro) .strokeWidth(0f) .fillColor(0x550000FF) );
Jul x, 2022 at 13:45
How would you brand it so the circle remains in the heart of the map every bit the user moves across the map?
Jan 19, 2022 at 7:04