1

I would really like to know is there some tutorial or example on how to draw the blue circles that appear in the google maps app (the one that show you where u are). I would also like to know how when u zoom in the circle becomes bigger (and when zooming out the circle becomes smaller and at some point disappears). If there are some suggestions or guides lines for this, or where to begin, I would really appreciate it. Thank u

Sandra
  • 4,239
  • 10
  • 47
  • 80

2 Answers2

1

After long looking for an answer I finally got a solution. Here is my code:

           int mToR= metersToRadius(55, mapView,p.getLatitudeE6());
           canvas.drawCircle(screenPts.x, screenPts.y, mToR, mPaintFill);
           canvas.drawCircle(screenPts.x, screenPts.y, mToR, mPaintStroke);

This draws the circle, where screenPts is a projection of the GeoPoint of my current location.

public static int metersToRadius(float meters, MapView map, double latitude) {
    return (int) (map.getProjection().metersToEquatorPixels(meters) * (1/ Math.cos(Math.toRadians(latitude))));         
}

This is how I calculate the radius of the circle. This I got from some other post (http://stackoverflow.com/questions/2077054/how-to-compute-a-radius-around-a-point-in-an-android-mapview)

Sandra
  • 4,239
  • 10
  • 47
  • 80
  • I know I answered my question but after using my app for several days I noticed that the radius of the circle changes even thou I put it to be always 55 meters. If someone knows why this is happening or has a better solution for this problem, I will very much appreciate it if he shares it. Thank u in advance. – Sandra Aug 09 '11 at 14:08
0

Most drawing operations are available in the Canvas class: http://developer.android.com/reference/android/graphics/Canvas.html

As far as I know there is no direct way to draw the blue circles directly, but you should be able to emulate it closely through some calls to drawCircle()

Bruno Oliveira
  • 5,056
  • 18
  • 24