2011年3月28日 星期一

[ Google Earth ]運用圖層在地球上貼上標誌


上面範例儲存在http://cce.nkut.edu.tw/ccemark.html
我們可以利用圖層技術在一個畫面上疊加另一個視窗來顯示標誌或符號。 ScreenOverlays可用來建立此疊加技術。定位覆蓋是通過映射方法把標誌顯示在圖像中某一點上,我們可以指定screenXY屬性。,指定的rotationXY屬性也可以旋轉該圖像,透過指定旋轉角度。
function initCallback(object) {
ge = object;
ge.getWindow().setVisibility(true);
placemark = ge.createPlacemark('');
var lookAt = ge.createLookAt('');
lookAt.setLatitude(23.979901);
lookAt.setLongitude(120.696874);
lookAt.setRange(1000.0);
ge.getView().setAbstractView(lookAt);

// Create the ScreenOverlay.
var screenOverlay = ge.createScreenOverlay('');

// Specify a path to the image and set as the icon.
var icon = ge.createIcon('');
icon.setHref('http://cce.nkut.edu.tw/images/cce.jpg');
screenOverlay.setIcon(icon);

// Important note: due to a bug in the API, screenXY and overlayXY
// have opposite meanings than their KML counterparts. This means
// that in the API, screenXY defines the point on the overlay image
// that is mapped to a point on the screen, defined by overlayXY.

// This bug will not be fixed until the next major revision of the
// Earth API, so that applications built upon version 1.x will
// not break.

// Set the ScreenOverlay's position in the window.
screenOverlay.getOverlayXY().setXUnits(ge.UNITS_PIXELS);
screenOverlay.getOverlayXY().setYUnits(ge.UNITS_PIXELS);
screenOverlay.getOverlayXY().setX(200);
screenOverlay.getOverlayXY().setY(200);

// Specify the point in the image around which to rotate.
screenOverlay.getRotationXY().setXUnits(ge.UNITS_FRACTION);
screenOverlay.getRotationXY().setYUnits(ge.UNITS_FRACTION);
screenOverlay.getRotationXY().setX(0.5);
screenOverlay.getRotationXY().setY(0.5);

// Set the overlay's size in pixels.
screenOverlay.getSize().setXUnits(ge.UNITS_PIXELS);
screenOverlay.getSize().setYUnits(ge.UNITS_PIXELS);
screenOverlay.getSize().setX(250);
screenOverlay.getSize().setY(75);

// Rotate the overlay.
screenOverlay.setRotation(25);

// Add the ScreenOverlay to Earth.
ge.getFeatures().appendChild(screenOverlay);


}

沒有留言:

張貼留言