<< Click to Display Table of Contents >>

取得圖台物件

 

 

檢視範例

範例下載

 

 

<說明>

在地圖基本控制項中,建立地圖有可能須取得相關的物件及其數值,3D API提供若干方式來獲取相關物件資訊。如欲獲得容器div的標籤或寬高,可利用getElementById()的方法;如果想取得目前地圖物件的中心點坐標,可利用GetCamera()的方法。另外也可以取得地圖邊框範圍、地圖縮放層級、目前地圖類型等地圖相關物件參數。

 

 

<範例>

         function documentLoad()

       {

             SuperGIS.Initialize("/ServerGate/", function () {

                 SuperGIS.ServerEarth.Initialize(InitEarth);

             });

         }

 

     function InitEarth()

     {

         //var pBody = new SuperGIS.Windows.HTMLContainer(document.body);

         var pBody = new SuperGIS.Windows.HTMLContainer(document.getElementById("example"));

 

         var sHost = location.href;

         var idx = sHost.indexOf("/", 8);

         if (idx >= 0) sHost = sHost.substring(0, idx);

         CreateHTML5Earth(pBody, function (pEarth) { EarthLoaded(pEarth); });

 

         function EarthLoaded(pEarth)

         {

             pEarth.Scene.BackgroundColor = pEarth.CreateColor(0, 0, 0, 1);

             pEarth.SetupSystem(true, s_WGS84);

             pEarth.SetupSkin(pEarth.CreateEnvelope(-180, 180, -90, 90, s_WGS84), sHost + "/ServerGate/Skin1.jpg");

 

               // 取得目前頁面容器資訊

             var mapDiv = document.getElementById("example");

             // mapDiv.style.width: 寬

             // mapDiv.style.eight: 高

 

               // 取得目前 Viewpoint (Camera 所在位置屬性)

             var pCam = pEarth.GetCamera();

             var pos = pCam.Position; // Camera 的位置坐標為 Earth 的坐標系統 (X, Y, Z), Z 為高度 (公尺)

             var v1 = pCam.Pitch; // X 軸旋轉角度, 一般所知的傾角 (Tilt)

             var v2 = pCam.Roll; // Y 軸旋轉角度, 固定限制為 0

             var v3 = pCam.Yaw; // Z 軸旋轉角度, 一般所知的方位角, 朝正北為 0

         }

       }

 

 

 

 

 


© 2017 Supergeo Technologies Inc.