Wednesday, November 18, 2009

[android-developers] Re: Draw Bitmap on Overlay

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 <nithin.war...@gmail.com> 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 <sorni...@fooz.dk> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate