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 8116017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:40:36+00:00 2026-06-06T03:40:36+00:00

I am attempting to draw a custom Drawable overlay on a MapView. I use

  • 0

I am attempting to draw a custom Drawable overlay on a MapView.
I use a custom class that extends Drawable to draw the circle on a canvas. Then I pass a radius variable to it and add it to an ItemizedOverlay which gets applied to the MapView.

So far it is working out pretty well, but for some reason, the canvas.drawCircle method is drawing a transparent circle with what looks like an ellipse inside of it, and I can’t, for the life of me, figure out what is causing it. I do want the circle to be transparent, but I don’t want this ellipse thing inside of it.

Here is the custom Drawable class:

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
public class PileDrawable extends Drawable {
    private static final Paint paint = new Paint();
    int rad;
    public PileDrawable(int radius) {
            paint.setARGB(100, 0, 255, 0);
            paint.setAntiAlias(false);
            paint.setStyle(Paint.Style.FILL);
            rad=radius;
    }
    @Override
    public void draw(Canvas canvas) {

            canvas.drawCircle(0, 0, rad, paint);

    }
    @Override
    public int getOpacity() {
            return 0;
    }
    @Override
    public void setAlpha(int alpha) {

    }
    @Override
    public void setColorFilter(ColorFilter cf) {

    }
}

This is kind of what it looks like, ignore my lack of MS paint skills…

http://img222.imageshack.us/img222/4356/circleellipse.png

I have a lingering feeling that the problem occurs when I apply the bounds to the Drawable.

PileDrawable pd = new PileDrawable((int)(mapView.getProjection().metersToEquatorPixels(Radius) * (1/ Math.cos(Math.toRadians(point.getLatitudeE6()))))); 
     pd.setBounds(0,0,pd.getIntrinsicWidth(),pd.getIntrinsicHeight()); //HERE?

So, any ideas?

  • 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-06-06T03:40:38+00:00Added an answer on June 6, 2026 at 3:40 am

    it might be a little late, but here is how i draw a circle on the map as an overlay. hope this helps people in the future

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow)
    {
            Projection proj = mapView.getProjection();
            GeoPoint loc = new GeoPoint(geo.getLat(), geo.getLng());
    
            Point point = new Point();
            proj.toPixels(loc, point);
            float rad = (float) (proj.metersToEquatorPixels(radius) * (1 / Math.cos(Math.toRadians(loc.getLatitudeE6() / 1000000))));
    
            Paint circle = new Paint();
            circle.setColor(colour);
            circle.setAlpha(30);
            circle.setAntiAlias(true);
            circle.setStyle(Style.FILL);
    
            canvas.drawCircle(point.x, point.y, rad, circle);
    
            super.draw(canvas, mapView, shadow);
    
    }
    

    and works like a charm. i am not sure as to why the ellipse is drawn since there is nothing in the code to draw a ellipse, but i am guessing it could be cause of the integer value conversion rather than the float value conversion, while u initialize the PileDrawable

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to do SetData() on Texture2D that has been recently Draw()-n by SpriteBatch leads
I'm trying to use a custom textfield background. The problem is that the text
I am attempting to draw a sidebar for a project that I am working
So, i'm attempting simple card game. I have player class with draw function, and
I'm attempting to draw to screen with a bunch of colors that I have
I am attempting to use jqplot to draw a stacked bar chart with the
I am attempting to use PyQT to position and display a custom widget. Thus
I'm attempting to draw to a Canvas inside each element of a ListView. Currently
I'm attempting to use .png files I've created in paint.net as drawable resources to
I am attempting to draw a dynamic PNG image (one that is generated by

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.