I think the projection is causing the problem. Here's a copy of my
Projection-object:
projection PixelConverter (id=830060753840)
+ mInverse Matrix (id=830060753992)
+ mMap Map (id=830060693368)
biller MapBiller (id=830060694872)
centerPixelX 2610768
centerPixelY 1626375
completeTilesInViewport 0
displayHeight 0
displayWidth 0
earliestTileNeededTime 0
halfHeight 0
halfWidth 0
isViewportAllNew false
lastPaintStartTime 0
layerServices Vector (id=830060693664)
mapService MapService (id=830060696344)
mapState MapState (id=830060726304)
pixelMapper null
running true
tileOverlayRenderer AndroidTileOverlayRenderer
(id=830060769480)
tiles null
topLeftTile Tile (id=830060726360)
xTiles 0
yTiles 0
+ mMatrix Matrix (id=830060753976)
+ mTempFloats float[2] (id=830060754008)
+ mTempPoint Point (id=830060754320)
If you need any further information please say so.
On 18 Nov., 16:15, Søren <[email protected]> wrote:
> This is the method for drawing circles:
>
> private Canvas drawCircle(Canvas canvas, GeoPoint gp)
> {
> Point p = new Point();
> _projection.toPixels(gp, p);
>
> // Create gradient circle
> int[] gradientColors = new
> int[]{Color.BLACK,Color.TRANSPARENT};
> Shader gradientShader = new RadialGradient(p.x, p.y, _radius,
> gradientColors, null, TileMode.CLAMP);
>
> // Create and setup paint brush
> Paint paint = new Paint();
> paint.setAntiAlias(true);
> paint.setShader(gradientShader); // Add gradient circle
> canvas.drawPaint(paint);
>
> return canvas;
> }
>
> It works ok, the only thing wrong is that the circles center is at
> -344668x21990 and that is clearly not on the screen.
>
> On 18 Nov., 16:04, Søren <[email protected]> wrote:
>
> > But the toPixels is still wrong.
>
> > What I'm doing is, I'm drawing lots of circles on a canvas, then I
> > take the bitmap and recolours the circles as one blob. I then want to
> > draw that bitmap to my overlay canvas.
>
> > I can easily draw, but when I transform my GeoPoint to screenPoints I
> > get the values stated in my second post:
>
> > GeoPoint: 35908138x14500975
> > Center of screen: -344668x21990
>
> > And that's just wrong.
>
> > On 18 Nov., 15:48, Nithin <[email protected]> wrote:
>
> > > Hi,
>
> > > u try like this..
>
> > > Point p = new Point();
> > > _mapView.getProjection().toPixels(_gp, p);
>
> > > Then, in canvas.drawBitmap(), try like this...
>
> > > canvas.drawBitmap(bmp, p.x, p.y, null);
>
> > > Thanks
> > > Nithin
>
> > > On Nov 18, 6:50 pm, Søren <[email protected]> wrote:
>
> > > > I think I'm getting there, but it seems like my projection isn't
> > > > working. This is my onCreate-method in my MapActivity:
>
> > > > public void onCreate(Bundle savedInstanceState)
> > > > {
> > > > super.onCreate(savedInstanceState);
> > > > setContentView(R.layout.map);
>
> > > > _mapView = (MapView)findViewById(R.id.mapView);
> > > > _mapView.setBuiltInZoomControls(true);
>
> > > > _mapController = _mapView.getController();
> > > > double lat = 35.908138*1E6;
> > > > double lng = 14.500975*1E6;
>
> > > > _gp = new GeoPoint((int)lat,(int)lng);
> > > > Point p = _mapView.getProjection().toPixels(_gp, null);
>
> > > > // Add overlay
> > > > _moodOverlay = new MoodOverlay();
> > > > List<Overlay> overlays = _mapView.getOverlays();
> > > > overlays.add(_moodOverlay);
>
> > > > _mapController.animateTo(_gp);
> > > > _mapController.setZoom(17);
>
> > > > System.out.println("GeoPoint: " + _gp.getLatitudeE6() + "x" +
> > > > _gp.getLongitudeE6());
> > > > System.out.println("Center of screen: " + p.x + "x" + p.y);
> > > > }
>
> > > > The problem is that the toPixels is totally wrong. It print's the
> > > > following:
>
> > > > GeoPoint: 35908138x14500975
> > > > Center of screen: -344668x21990
>
> > > > What is wrong here?
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en