Hey folks,

While it would still be extremely useful to be able to access the BitmapData
of a GroundOverlay layer directly, but here's a (somewhat hacky) solution I
found.  I access the transformation the Google Maps library calculates for a
bitmap of the proper size through the 'concatenatedMatrix' property, and
then create a clipped bitmap and position it in the component (of the size
of my original bitmap).  It's not a great solution -- you need to watch for
events that change the zoom or pan and update your component -- but it
works.  You could probably use a similar strategy if you were struggling
with the initial size of your bitmap, as well.

Here's a code snippit for inspiration in case anyone hits this problem in
the future:

public function cropBitmapToViewport():void {

var contentBitmapData:BitmapData =
this.getContentBitmapData(originalBitmap.bitmapData,
this.currentSliderValue);

var matrix:Matrix = this.transform.concatenatedMatrix;


 var xshift:Number = matrix.tx;

 var yshift:Number = matrix.ty;

var xscale:Number = matrix.a;

var yscale:Number = matrix.d;


// What width and height does our cropped bitmap need to be to cover the
viewport, plus a buffer area?

var pixelWidth:Number = (MAX_MAP_WIDTH + BUFFER*2) / xscale;

var pixelHeight:Number = (MAX_MAP_HEIGHT + BUFFER*2) / yscale;


 // If we don't need to crop the bitmap, we don't.

 if ( isScaledBitmapSafe() ) {

 this.bitmap.x = 0;

this.bitmap.y = 0;

this.bitmap.bitmapData = contentBitmapData;

return;

 }


 var croppedBitmapData:BitmapData = new
BitmapData(pixelWidth,pixelHeight,true);


 this.bitmap.bitmapData = croppedBitmapData;

 // Set x and y of our cropped bitmap to match the original

 this.bitmap.x =  Math.floor((0 - xshift) / xscale) - (BUFFER / xscale) ;

 this.bitmap.y =  Math.floor((0 - yshift) / yscale) - (BUFFER / xscale);


// Copy the content from the origianal bitmap

bitmap.bitmapData.copyPixels(

 contentBitmapData,

new Rectangle(bitmap.x, bitmap.y, pixelWidth, pixelHeight), new Point(0,0)

);

}

--j

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" 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/google-maps-api-for-flash?hl=en.

Reply via email to