My known data is my current location (GeoPoint) and radius in meters. I want to draw a circle around my current location based on the map projection and radius. My overlay of map view overrides the drawing method like
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { Projection projection = mapView.getProjection(); GeoPoint myLocationGeoPoint = getLocationGeoPointFromSomeSource(); Point myPoint = new Point(); projection.toPixels(myLocationGeoPoint, myPoint); int radiusPixel = (int) projection.metersToEquatorPixels(getRadiusInMetersFromSomeSource()); canvas.drawCircle(myPoint.x, myPoint.y, radiusPixel, mPaintStroke); canvas.drawCircle(myPoint.x, myPoint.y, radiusPixel, mPaintFill); super.draw(canvas, mapView, shadow); }
The problem with this code is that radiusPixel too small. I assume the problem is with the metersToEquatorPixels method, which takes a parameter in meters and calculates approx. pixels if these meters are at the equator. I'm right? But I want to calculate how many pixels my radius occupies, not only if I stand at the equator. Is there a built-in function for this kind of work or do I need to do this manually?
Hi
zmeda source share