Kazu46Machi / earth-api-samples

Automatically exported from code.google.com/p/earth-api-samples
0 stars 0 forks source link

Display screenoverlay using fractional size but with correct bitmap aspect ratio #197

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Not sure if this is a bug of feature.

I need to place a bitmap screenoverlay with a fractional height of 1.
However, there is no way to determine what the fractional width should be.

In it's most primitive form I need to be able to read the GE window size
but the window object doesn't offer width and height.

But an enhancement to the otherwise awesome fractional positioning system
would be the ability to do the following:

var icon = ge.createIcon('');
icon.setHref('http://myBitmap.png');

overlay.getSize().setXUnits(ge.UNITS_PIXELS);
overlay.getSize().setYUnits(ge.UNITS_FRACTION);
overlay.getSize().setY(1);
ge.getFeatures().appendChild(overlay);
overlay.getSize().setYUnits(ge.UNITS_PIXELS);
overlay.getSize().setX(helpPad.getSize().getY() * icon.aspectratio);

The Icon object knows the native bitmap width, height and aspectratio.
By changing the YUnits from fraction to pixel after the assignment should
allow me to read out the pixel value of the current height.

(I hope I have not overlooked an existing solution and if so I apologise
for wasting your time)

Original issue reported on code.google.com by vandint...@gmail.com on 1 Apr 2009 at 9:22

GoogleCodeExporter commented 8 years ago
The latest documentation states:

Specifies the size of the image for the screen overlay, as follows

    * A value of -1 indicates to use the native dimension
    * A value of 0 indicates to maintain the aspect ratio
    * A value of n sets the value of the dimension 

But this is not enough. If I want to place an image immediately to the right of 
the
first image I need to know what the actual fractional width of the first bitmap 
was.
The current API won't allow me to find out.

The cleanest and simplest way I can think of solving this is a width and height
property for a kmlIcon that tells me the bitmap width and height in pixels. 
That way
I can calculate everything I need to know.

Also, a size of -1 or 0 is a special size. I think getSize should still report 
back
the actual size in the appropriate units.

So basically, setSize value 0 is not all that usefull because although it 
allows me
to display a bitmap at the correct aspect ratio, it won't be enough to let me do
anything with it because I still don't know the real size.

Original comment by vandint...@gmail.com on 27 May 2010 at 10:36