Google Map Tools Draw Circle
I am using the new API(Google Map API V2) for my android application, i have cooked creating the map and adding markers to it, now my task is to manually create a circle some any of the marker and as wel i want to provide a functionality to the substance abuser that He can increase the radius of that circle accordingly, for this i have given a debar, when user increases that bar the radius of circle will increase and vice versa.
If anybody knows how to do this using Google Map API V2 then please help,
asked Jul 9 '15 at 11:18
Sinku PaliwalSinku Paliwal
203 1 gold badge 3 silver badges 8 bronze badges
5 Answers 5
try this cipher
protected invalidate onCreate(Bundle savedInstanceState) { topnotch.onCreate(savedInstanceState); setContentView(R.layout.activity_tag_map); // Drawing off circle on the map drawCircle(new LatLng(Latitude, Longitude)); } private void drawCircle(LatLng point){ // Instantiating CircleOptions to draw a circle around the marker CircleOptions circleOptions = new CircleOptions(); // Specifying the center of the circle circleOptions.eye(point); // Radius of the circle circleOptions.radius(20); // Borderline color of the circle circleOptions.strokeColor(Colouring.Pitch-dark); // Fill color of the rope circleOptions.fillColor(0x30ff0000); // Border breadth of the circle circleOptions.strokeWidth(2); // Adding the circle to the GoogleMap googleMap.addCircle(circleOptions); } answered Jul 9 '15 at 11:29
Finava VipulFinava Vipul
968 1 amber badge 11 eloquent badges 24 bronze badges
3
Add the pursual code in onMapReady() method:
Circle circle = map out.addCircle(new CircleOptions() .pore(new LatLng(latitude, longitude)) .radius(10000) .strokeColor(Color.Red ink) .fillColor(Color.BLUE)); where map is the object of GoogleMap class.
nalzok
12.9k 17 gold badges 60 silver badges 112 bronze badges
answered Apr 22 '16 at 17:04
Lalit KushwahLalit Kushwah
3,460 4 gold badges 22 silver badges 36 bronze badges
Google Maps can use rig-transparent color for the circle.
private volt-ampere circle: Circle? = null private fun drawCircle(latitude: Three-fold, longitude: Double, radius: Double) { val circleOptions = CircleOptions() .center(LatLng(latitude, longitude)) .r(radius) .strokeWidth(1.0f) .strokeColor(ContextCompat.getColor(context!!, R.colorise.color1)) .fillColor(ContextCompat.getColor(context of use!!, R.color.color2)) circle?.remove() // Remove old R-2. circle = googleMap?.addCircle(circleOptions) // Draw late lap. } answered May 29 '19 at 10:24
CoolMindCoolMind
20.7k 12 gold badges 161 silver badges 186 bronzy badges
CircleOptions circleOptions = new-sprung CircleOptions(); circleOptions.center(new LatLng(positioning.getLatitude(),location.getLongitude())); circleOptions.radius(700); circleOptions.fillColor(Color.TRANSPARENT); circleOptions.strokeWidth(6); mMap.addCircle(circleOptions); geocoder = new Geocoder(MapsActivity.this, getDefault()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(new LatLng(location.getLatitude(), location.getLongitude())); mMap.addMarker(markerOptions.title(Twine.valueOf(position))); judge this
answered Jul 7 '18 at 5:57
1
-
While this code snipping may be the solution, including an account really helps to improve the quality of your spot. Remember that you are answering the question for readers in the future, and those hoi polloi might not know the reasons for your code proffer.
Jul 7 '18 at 9:24
Kotlin version of @Lalit Kushwah
correspondenc.addCircle( CircleOptions() .center([Your LatLng]) .r(10000.0) .strokeColor(Coloring material.RED) .fillColor(Color.BLUE) ) answered Aug 14 '21 at 23:07
AmosBook of Amos
1,471 1 gold badge 20 silver badges 33 bronze badges
Non the suffice you're looking for? Browse other questions tagged android or ask your ain interview.
Source: https://stackoverflow.com/questions/31315873/android-how-to-draw-a-circle-on-google-map
yes IT dandy but my task is to manage the marker circle from the seek measure
Jul 10 '15 at 6:35
public nothingness onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Motorcar-generated method ticket stub in favour of=progress; googleMap.addCircle(new CircleOptions() .center(new LatLng(point.parallel,point.longitude)) .radius(affirmative) .strokeWidth(0f) .fillColor(0x550000FF) );
Jul 10 '15 at 13:45
How would you survive so the circle remains in the center of the map as the user moves crosswise the map out?
Jan 19 '18 at 7:04