Monday, July 30, 2012

[android-developers] Re: Zooming on a custom overlay

Hey Igor,
I am trying to subclass the Overlay class so that I can pull tiles (generated from MapTiler) from a website and put them on top of Google Maps that are showing.  I am tryng to do this in Android.  Could you provide some sample code that might help?
Any and all help is appreciated.

On Wednesday, November 17, 2010 2:16:22 PM UTC-5, Igor Prilepov wrote:
I used the Overlay class for this purpose.
Here is the main part of the MyOverlay::Draw() method:
        // convert bitmap's bounding box into pixels
        Point top_left = new Point();
        mapView.getProjection().toPixels(min, top_left);
        Point bottom_right = new Point();
        mapView.getProjection().toPixels(max, bottom_right);

        // Prepare two rectangles (pixels)
        Rect src = new Rect( 0,0,bmp.getWidth() - 1, bmp.getHeight() - 1 );
        Rect dst = new Rect( top_left.x, bottom_right.y,
bottom_right.x,top_left.y );

        // draw bitmap
        canvas.drawBitmap( bmp, src, dst, null);

Since it uses current mapView then zooming and panning are supported

Obviously you need to now left top (GeoPoint min in the code above)
and right bottom (GeoPoint max) coordinates for your picture (I used
Google Earth for this purpose).

Good luck.

On Nov 17, 7:52 am, Allan Valeriano <> wrote:
> Hi all,
> does anybody knows if it is possible to zoom in and out on a custom
> overlay and enlarge the image?
> I'd like to do something like that:
> If you zoom in, you'll notice that the image gets bigger.

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment