Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:23:18+00:00 2026-05-26T10:23:18+00:00

I want to draw a circle on MapView, i.e. radius. I do it like

  • 0

I want to draw a circle on MapView, i.e. radius. I do it like this:

Overlay to draw circle:

public class RadiusOverlay extends Overlay {

    private Context context;
    private double latitude;
    private double longitude;
    private float radius;

    public RadiusOverlay(Context context, double latitude, double longitude, float radius){
     /*.....................*/
    }

    public void draw(Canvas canvas, MapView mapView, boolean shadow){
        super.draw(canvas, mapView, shadow); 

        Point point = new Point();
        GeoPoint geoPoint = new GeoPoint((int) (latitude *1e6), (int)(longitude * 1e6));

        Projection projection = mapView.getProjection();
        projection.toPixels(geoPoint, point);
        radius = projection.metersToEquatorPixels(radius);

        Paint paint = new Paint();
        paint.setStyle(Paint.Style.FILL);
        paint.setARGB(100, 100, 100, 100);

        canvas.drawCircle((float)point.x, (float)point.y, radius, paint);
    }

}

In MapActivity:

List<Overlay> mapOverlays = mapView.getOverlays();
RadiusOverlay radiusOverlay = new RadiusOverlay(this, latitude, longitude, radius);
mapOverlays.add(radiusOverlay);

I see circle when MapActivity starts, and it’s the size I intended, but then it grows to the size of the screen and disappears. How do I fix this?
Will appreciate any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:23:19+00:00Added an answer on May 26, 2026 at 10:23 am

    It looks like you are re-calculating the radius using metersToEquatorPixels every time you draw it. You should move that calculation to the constructor and see if that fixes your problem.

    EDIT:

    As Olgas pointed out, the Projection can change. Therefore what you want to do is store the original `radius value as you are, then in your draw method do:

        float projectedRadius = projection.metersToEquatorPixels(radius);
    

    and use this value later in draw as well:

        canvas.drawCircle((float)point.x, (float)point.y, projectedRadius, paint);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to draw simple 2D objects like circle, line, square etc in
in this my gps application i want to draw circle around my current location
Following Mootools class helps developer to draw a circle overlay on Google Map using
I want to draw this type of circle in my application. I am able
I want to draw an image in PHP, which looks like the circle in
I want to draw a 2d, filled, circle. I've looked everywhere and cannot seem
I want to draw some listview items disabled and would like to mimic the
I want to draw this in my view to draw this line, I have
I want to draw a graph in my Django-based site, to look like these
I am new to WPF. I want to draw a small circle on Canvas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.